commit
aa15515837
|
@ -16,10 +16,11 @@ Makefile
|
||||||
|
|
||||||
# Ignore targets
|
# Ignore targets
|
||||||
/colobot
|
/colobot
|
||||||
|
/src/CBot/libCBot.so
|
||||||
|
|
||||||
# Ignore local data
|
# Ignore local data
|
||||||
/colobot.ini
|
/colobot.ini
|
||||||
/savegame
|
/saves
|
||||||
|
|
||||||
# Standard build directory
|
# Standard build directory
|
||||||
/build
|
/build
|
||||||
|
|
|
@ -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 6)
|
set(COLOBOT_VERSION_REVISION 7)
|
||||||
|
|
||||||
# Used on official releases
|
# Used on official releases
|
||||||
set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
|
set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
|
||||||
|
@ -94,8 +94,6 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||||
|
|
||||||
# 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(USE_SDL_MAIN 1) # fixes SDL_main
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Build for other system")
|
message(STATUS "Build for other system")
|
||||||
set(PLATFORM_WINDOWS 0)
|
set(PLATFORM_WINDOWS 0)
|
||||||
|
@ -178,6 +176,10 @@ option(ASSERTS "Enable assert()s" ON)
|
||||||
# Development build can be enabled/disabled regardless of build type
|
# Development build can be enabled/disabled regardless of build type
|
||||||
option(DEV_BUILD "Enable development build (enables some debugging tools, local setting paths, etc.)" OFF)
|
option(DEV_BUILD "Enable development build (enables some debugging tools, local setting paths, etc.)" OFF)
|
||||||
|
|
||||||
|
# Official build - changes text on the crash screen
|
||||||
|
# PLEASE DO NOT USE ON UNOFFICIAL BUILDS. Thanks.
|
||||||
|
option(OFFICIAL_BUILD "Official build (changes crash screen text)" OFF)
|
||||||
|
|
||||||
# Portable build - load all data from current directory
|
# Portable build - load all data from current directory
|
||||||
option(PORTABLE "Portable build" OFF)
|
option(PORTABLE "Portable build" OFF)
|
||||||
|
|
||||||
|
@ -229,9 +231,9 @@ endif()
|
||||||
##
|
##
|
||||||
|
|
||||||
find_package(OpenGL 1.4 REQUIRED)
|
find_package(OpenGL 1.4 REQUIRED)
|
||||||
find_package(SDL 1.2.10 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_package(SDL_image 1.2 REQUIRED)
|
find_package(SDL2_image REQUIRED)
|
||||||
find_package(SDL_ttf 2.0 REQUIRED)
|
find_package(SDL2_ttf REQUIRED)
|
||||||
find_package(PNG 1.2 REQUIRED)
|
find_package(PNG 1.2 REQUIRED)
|
||||||
find_package(Gettext REQUIRED)
|
find_package(Gettext REQUIRED)
|
||||||
find_package(PhysFS REQUIRED)
|
find_package(PhysFS REQUIRED)
|
||||||
|
@ -291,25 +293,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
message(STATUS "Adding MSVC-specific options")
|
message(STATUS "Adding MSVC-specific options")
|
||||||
|
|
||||||
set(CBOT_STATIC 1) # only this works for some reason
|
set(CBOT_STATIC 1) # only this works for some reason
|
||||||
set(USE_SDL_MAIN 1) # fixes SDL_main
|
|
||||||
set(WINGETOPT 1) # use wingetopt library
|
set(WINGETOPT 1) # use wingetopt library
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##
|
|
||||||
# Clipboard support needs X11 libraries
|
|
||||||
##
|
|
||||||
if(PLATFORM_GNU)
|
|
||||||
find_package(X11 REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
# Clipboard support
|
|
||||||
##
|
|
||||||
set(CLIPBOARD_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/clipboard/include)
|
|
||||||
add_subdirectory(lib/clipboard)
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Localename
|
# Localename
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
# How to contribute
|
# How to contribute
|
||||||
**NOTE: This document is still not finished. Please feel free to suggest any changes.**
|
|
||||||
|
|
||||||
So you want to contribute to Colobot: Gold Edition? That's awesome! Before you start, read this page, it contains a lot of useful information on how to do so.
|
So you want to contribute to Colobot: Gold Edition? That's awesome! Before you start, read this page, it contains a lot of useful information on how to do so.
|
||||||
|
|
||||||
## General information
|
## General information
|
||||||
Before you start, read more about technical details of the project. They can be found on the [dev wiki](http://colobot.info/wiki/dev) and in our [Game Design Document](http://compiled.colobot.info/jenkins/job/colobot-gold-gdd/lastSuccessfulBuild/artifact/Colobot_Gold_Edition-Game_Design_Document.pdf) ([live editor](http://krzysh.pl:3000/project/545e90d99e8bceed2284797e))
|
Before you start, read more about technical details of the project. They can be found in our [Game Design Document](http://compiled.colobot.info/jenkins/job/colobot-gold-gdd/lastSuccessfulBuild/artifact/Colobot_Gold_Edition-Game_Design_Document.pdf) ([live editor](http://krzysh.pl:3000/project/545e90d99e8bceed2284797e)).
|
||||||
|
|
||||||
|
You may also find some useful information on the our (outdated) [dev wiki](http://colobot.info/wiki/dev).
|
||||||
|
|
||||||
## Before you start coding
|
## Before you start coding
|
||||||
* If you want to fix a bug, please first check the related [issue on GitHub's bug tracker](https://github.com/colobot/colobot/issues). If there isn't one, make it.
|
* If you want to fix a bug, please first check the related [issue on GitHub's bug tracker](https://github.com/colobot/colobot/issues). If there isn't one, make it.
|
||||||
* If you want to add a new feature or make any change to gameplay, please first discuss it either [on the forums](http://colobot.info/forum) or in the related issue on GitHub. When your issue gets *enhancement* label (without the *(proposed)* part), that means that your suggestion got accepted and is waiting for somebody to work on it. Always wait for your suggestion to be accepted before you start writing any code.
|
* If you want to add a new feature or make any change to gameplay, please first discuss it either [on the forums](http://colobot.info/forum) or in the related issue on GitHub. When your issue gets *accepted* label, that means that your suggestion got accepted and is waiting for somebody to work on it. Always wait for your suggestion to be accepted before you start writing any code.
|
||||||
* Before you start, check *"Assignee"* field in the issue and read the comments to see if nobody else is working on the same issue. If somebody is assigned to it, but there was no activity for a long time, you can take it over. Also, please post a comment on the issue that you want to help us, so other people don't waste time working at that issue in the same time.
|
* Before you start, check *"Assignee"* field in the issue and read the comments to see if nobody else is working on the same issue. If somebody is assigned to it, but there was no activity for a long time, you can take it over. Also, please post a comment on the issue that you want to help us, so other people don't waste time working at that issue in the same time.
|
||||||
|
|
||||||
## Coding guidelines
|
## Coding style
|
||||||
See the [related page on dev wiki](http://colobot.info/wiki/dev/Coding_rules).
|
See the [related page on dev wiki](http://colobot.info/wiki/dev/Coding_rules) for general guidelines, or [this file](https://github.com/colobot/colobot-lint/blob/master/RULES.md) for detailed description.
|
||||||
|
|
||||||
## Submitting Pull Requests
|
See [colobot-lint repository](https://github.com/colobot/colobot-lint) for automated tool that checks the coding style.
|
||||||
After you finish working on your issue and want your code to be merged into the main repository, you should submit a Pull Request. Go to [this page](https://github.com/colobot/colobot/pulls) and select "New pull request". All pull request should ALWAYS be submitted to the *dev* branch. After your PR gets reviewed by our development team, it'll be merged to *dev* branch, and later to the *master* branch (on the next release).
|
|
||||||
|
If your pull request breaks the coding style, you will have to fix it before it gets merged.
|
||||||
|
|
||||||
|
## Submitting pull requests
|
||||||
|
After you finish working on your issue and want your code to be merged into the main repository, you should submit a **pull request**. Go to [this page](https://github.com/colobot/colobot/pulls) and select "New pull request". All pull request should ALWAYS be submitted to the *dev* branch. After your PR gets reviewed by our development team, it will be merged to *dev* branch, and on the next release - to the *master* branch.
|
||||||
|
|
||||||
If you need more help, see [GitHub's help page on Pull Requests](https://help.github.com/articles/using-pull-requests/).
|
If you need more help, see [GitHub's help page on Pull Requests](https://help.github.com/articles/using-pull-requests/).
|
||||||
|
|
||||||
|
|
2438
Doxyfile.in
2438
Doxyfile.in
File diff suppressed because it is too large
Load Diff
|
@ -18,40 +18,52 @@ To cross-compile Colobot using MXE:
|
||||||
It already contains a universal Makefile for everything.
|
It already contains a universal Makefile for everything.
|
||||||
Usage is simply `make name_of_package`.
|
Usage is simply `make name_of_package`.
|
||||||
It will automatically check for dependencies, etc.
|
It will automatically check for dependencies, etc.
|
||||||
The packages will be installed in the MXE directory under `usr/`.
|
The packages will be installed in the MXE directory under `usr/i686-w64-mingw32.static`.
|
||||||
|
|
||||||
You need to `make gcc` first for basic compiler and then do the same
|
You need to `make gcc` first for basic compiler and then do the same
|
||||||
for some additional libraries. In the end, you should have the following
|
for some additional libraries. In the end, you should have the following
|
||||||
packages installed (this is the final listing of `usr/installed/`):
|
packages installed (this is the final listing of `usr/i686-w64-mingw32.static/installed/`):
|
||||||
* binutils
|
* binutils
|
||||||
* boost
|
* boost
|
||||||
* bzip2
|
* bzip2
|
||||||
* check-requirements
|
* cairo
|
||||||
|
* dbus
|
||||||
* expat
|
* expat
|
||||||
* flac
|
* flac
|
||||||
|
* fontconfig
|
||||||
* freetype
|
* freetype
|
||||||
|
* freetype-bootstrap
|
||||||
* gcc
|
* gcc
|
||||||
* gcc-gmp
|
* gcc-gmp
|
||||||
|
* gcc-isl
|
||||||
* gcc-mpc
|
* gcc-mpc
|
||||||
* gcc-mpfr
|
* gcc-mpfr
|
||||||
* gettext
|
* gettext
|
||||||
* glew
|
* glew
|
||||||
|
* glib
|
||||||
|
* harfbuzz
|
||||||
|
* icu4c
|
||||||
* jpeg
|
* jpeg
|
||||||
|
* libffi
|
||||||
* libiconv
|
* libiconv
|
||||||
* libpng
|
* libpng
|
||||||
* libsndfile
|
* libsndfile
|
||||||
* libtool
|
* libwebp
|
||||||
* mingwrt
|
* lzo
|
||||||
|
* mingw-w64
|
||||||
|
* mxe-conf
|
||||||
* ogg
|
* ogg
|
||||||
* openal
|
* openal
|
||||||
|
* pcre
|
||||||
* physfs
|
* physfs
|
||||||
|
* pixman
|
||||||
|
* pkgconf
|
||||||
* portaudio
|
* portaudio
|
||||||
* sdl
|
* sdl2
|
||||||
* sdl_image
|
* sdl2_image
|
||||||
* sdl_ttf
|
* sdl2_ttf
|
||||||
* tiff
|
* tiff
|
||||||
* vorbis
|
* vorbis
|
||||||
* w32api
|
|
||||||
* xz
|
* xz
|
||||||
* zlib
|
* zlib
|
||||||
|
|
||||||
|
@ -60,7 +72,7 @@ To cross-compile Colobot using MXE:
|
||||||
`mkdir build-mxe && cd build-mxe`
|
`mkdir build-mxe && cd build-mxe`
|
||||||
|
|
||||||
In order to cross-compile a CMake project, you have to specify a CMake toolchain file.
|
In order to cross-compile a CMake project, you have to specify a CMake toolchain file.
|
||||||
MXE has such file in MXE's directory: `usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake`
|
MXE has such file in MXE's directory: `usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake`
|
||||||
So you should use the following cmake command: `cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe-conf.cmake ..`
|
So you should use the following cmake command: `cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe-conf.cmake ..`
|
||||||
CMake files in Colobot should detect that MXE is being used and they will
|
CMake files in Colobot should detect that MXE is being used and they will
|
||||||
modify flags, paths, etc. as required. You should not run into any problems.
|
modify flags, paths, etc. as required. You should not run into any problems.
|
||||||
|
@ -74,6 +86,6 @@ To cross-compile Colobot using MXE:
|
||||||
in MXE. Then you can create the NSIS installer that way:
|
in MXE. Then you can create the NSIS installer that way:
|
||||||
`PATH=/path/to/mxe/binaries:$PATH make package`
|
`PATH=/path/to/mxe/binaries:$PATH make package`
|
||||||
where `/path/to/mxe/binaries` is path to cross-compiled MXE binaries available
|
where `/path/to/mxe/binaries` is path to cross-compiled MXE binaries available
|
||||||
in MXE's directory under `usr/i686-pc-mingw32/bin`.
|
in MXE's directory under `usr/i686-w64-mingw32.static/bin`.
|
||||||
This will create a versioned colobot-$version.exe installer that will install Colobot
|
This will create a versioned colobot-$version.exe installer that will install Colobot
|
||||||
in system directories, add a shortcut in the start menu and setup an uninstaller.
|
in system directories, add a shortcut in the start menu and setup an uninstaller.
|
||||||
|
|
|
@ -8,7 +8,7 @@ After installing Developer Command Line Tools, you should have basic tools like
|
||||||
```
|
```
|
||||||
And then:
|
And then:
|
||||||
```bash
|
```bash
|
||||||
brew install cmake sdl sdl_image sdl_ttf boost glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget
|
brew install cmake sdl2 sdl2_image sdl2_ttf boost glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget
|
||||||
```
|
```
|
||||||
Gettext is installed in separate directory without adding the files to system path, so in order to get it working normally, you should call also:
|
Gettext is installed in separate directory without adding the files to system path, so in order to get it working normally, you should call also:
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -56,9 +56,9 @@ You will need:
|
||||||
* recent compiler (GCC >= 4.7, or Clang >= 3.1) since we are using some features of C++11
|
* recent compiler (GCC >= 4.7, or Clang >= 3.1) since we are using some features of C++11
|
||||||
* CMake >= 2.8
|
* CMake >= 2.8
|
||||||
* Boost >= 1.51 (header files + components: filesystem and regex)
|
* Boost >= 1.51 (header files + components: filesystem and regex)
|
||||||
* SDL >= 1.2.10
|
* SDL2
|
||||||
* SDL_image >= 1.2
|
* SDL2_image
|
||||||
* SDL_ttf >= 2.0
|
* SDL2_ttf
|
||||||
* GLEW >= 1.8.0
|
* GLEW >= 1.8.0
|
||||||
* libpng >= 1.2
|
* libpng >= 1.2
|
||||||
* gettext >= 0.18
|
* gettext >= 0.18
|
||||||
|
@ -67,12 +67,11 @@ You will need:
|
||||||
* libogg >= 1.3.0
|
* libogg >= 1.3.0
|
||||||
* OpenAL (OpenAL-Soft) >= 1.13
|
* OpenAL (OpenAL-Soft) >= 1.13
|
||||||
* PhysFS
|
* PhysFS
|
||||||
* po4a >= 0.45 (to generate translated data files)
|
|
||||||
* oggenc (to generate music files)
|
* oggenc (to generate music files)
|
||||||
|
|
||||||
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 libsdl1.2debian libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libsdl-ttf2.0-0 libsdl-ttf2.0-dev libsdl-mixer1.2 libsdl-mixer1.2-dev libsndfile1-dev libvorbis-dev libogg-dev libpng12-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev 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 libpng12-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,
|
||||||
|
|
|
@ -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-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2016, 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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# English
|
# Colobot: Gold Edition
|
||||||
|
|
||||||
Welcome to the Colobot: Gold Edition project code repository
|
Welcome to the Colobot: Gold Edition project code repository
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
# Locate SDL2 library
|
||||||
|
# This module defines
|
||||||
|
# SDL2_LIBRARY, the name of the library to link against
|
||||||
|
# SDL2_FOUND, if false, do not try to link to SDL2
|
||||||
|
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||||
|
#
|
||||||
|
# This module responds to the the flag:
|
||||||
|
# SDL2_BUILDING_LIBRARY
|
||||||
|
# If this is defined, then no SDL2main will be linked in because
|
||||||
|
# only applications need main().
|
||||||
|
# Otherwise, it is assumed you are building an application and this
|
||||||
|
# module will attempt to locate and set the the proper link flags
|
||||||
|
# as part of the returned SDL2_LIBRARY variable.
|
||||||
|
#
|
||||||
|
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||||
|
# OS X framework based version. (Other versions link to -lSDL2main which
|
||||||
|
# this module will try to find on your behalf.) Also for OS X, this
|
||||||
|
# module will automatically add the -framework Cocoa on your behalf.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
|
||||||
|
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
|
||||||
|
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
|
||||||
|
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
||||||
|
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
||||||
|
# as appropriate. These values are used to generate the final SDL2_LIBRARY
|
||||||
|
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# $SDL2DIR is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SDL2DIR
|
||||||
|
# used in building SDL2.
|
||||||
|
# l.e.galup 9-20-02
|
||||||
|
#
|
||||||
|
# Modified by Eric Wing.
|
||||||
|
# Added code to assist with automated building by using environmental variables
|
||||||
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
# Added new modifications to recognize OS X frameworks and
|
||||||
|
# additional Unix paths (FreeBSD, etc).
|
||||||
|
# Also corrected the header search path to follow "proper" SDL guidelines.
|
||||||
|
# Added a search for SDL2main which is needed by some platforms.
|
||||||
|
# Added a search for threads which is needed by some platforms.
|
||||||
|
# Added needed compile switches for MinGW.
|
||||||
|
#
|
||||||
|
# On OSX, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SDL2_LIBRARY to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
#
|
||||||
|
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
|
||||||
|
# This needed to change because "proper" SDL convention
|
||||||
|
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
|
||||||
|
# reasons because not all systems place things in SDL2/ (see FreeBSD).
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2003-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
SET(SDL2_SEARCH_PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES include/SDL2 include
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(SDL2_LIBRARY_TEMP
|
||||||
|
NAMES SDL2
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
# Non-OS X framework versions expect you to also dynamically link to
|
||||||
|
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||||
|
# seem to provide SDL2main for compatibility even though they don't
|
||||||
|
# necessarily need it.
|
||||||
|
FIND_LIBRARY(SDL2MAIN_LIBRARY
|
||||||
|
NAMES SDL2main
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# SDL2 may require threads on your system.
|
||||||
|
# The Apple build may not need an explicit flag because one of the
|
||||||
|
# frameworks may already provide it.
|
||||||
|
# But for non-OSX systems, I will use the CMake Threads package.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# MinGW needs an additional library, mwindows
|
||||||
|
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
|
||||||
|
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||||
|
IF(MINGW)
|
||||||
|
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
IF(SDL2_LIBRARY_TEMP)
|
||||||
|
# For SDL2main
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(SDL2MAIN_LIBRARY)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(SDL2MAIN_LIBRARY)
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||||
|
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||||
|
# though it actually is there if I modify a pre-used variable.
|
||||||
|
# I think it has something to do with the CACHE STRING.
|
||||||
|
# So I use a temporary variable until the end so I can set the
|
||||||
|
# "real" variable in one-shot.
|
||||||
|
IF(APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
# For threads, as mentioned Apple doesn't need this.
|
||||||
|
# In fact, there seems to be a problem if I used the Threads package
|
||||||
|
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# For MinGW library
|
||||||
|
IF(MINGW)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
# Set the final string here so the GUI reflects the final state.
|
||||||
|
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||||
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
|
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
ENDIF(SDL2_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
|
@ -0,0 +1,158 @@
|
||||||
|
# Locate SDL2_image library
|
||||||
|
# This module defines
|
||||||
|
# SDL2_IMAGE_LIBRARY, the name of the library to link against
|
||||||
|
# SDL2_IMAGE_FOUND, if false, do not try to link to SDL2_image
|
||||||
|
# SDL2_IMAGE_INCLUDE_DIR, where to find SDL_image.h
|
||||||
|
#
|
||||||
|
# Additional Note: If you see an empty SDL2_IMAGE_LIBRARY_TEMP in your configuration
|
||||||
|
# and no SDL2_IMAGE_LIBRARY, it means CMake did not find your SDL2_Image library
|
||||||
|
# (SDL2_image.dll, libsdl2_image.so, SDL2_image.framework, etc).
|
||||||
|
# Set SDL2_IMAGE_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
||||||
|
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
||||||
|
# as appropriate. These values are used to generate the final SDL2_IMAGE_LIBRARY
|
||||||
|
# variable, but when these values are unset, SDL2_IMAGE_LIBRARY does not get created.
|
||||||
|
#
|
||||||
|
# $SDL2 is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SDL2
|
||||||
|
# used in building SDL2.
|
||||||
|
# l.e.galup 9-20-02
|
||||||
|
#
|
||||||
|
# Modified by Eric Wing.
|
||||||
|
# Added code to assist with automated building by using environmental variables
|
||||||
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
# Added new modifications to recognize OS X frameworks and
|
||||||
|
# additional Unix paths (FreeBSD, etc).
|
||||||
|
# Also corrected the header search path to follow "proper" SDL2 guidelines.
|
||||||
|
# Added a search for SDL2main which is needed by some platforms.
|
||||||
|
# Added a search for threads which is needed by some platforms.
|
||||||
|
# Added needed compile switches for MinGW.
|
||||||
|
#
|
||||||
|
# On OSX, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SDL2_IMAGE_LIBRARY to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
#
|
||||||
|
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
|
||||||
|
# This needed to change because "proper" SDL2 convention
|
||||||
|
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
|
||||||
|
# reasons because not all systems place things in SDL2/ (see FreeBSD).
|
||||||
|
#
|
||||||
|
# Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake
|
||||||
|
# module with the minor edit of changing "SDL" to "SDL2" where necessary. This
|
||||||
|
# was not created for redistribution, and exists temporarily pending official
|
||||||
|
# SDL2 CMake modules.
|
||||||
|
#
|
||||||
|
# Note that on windows this will only search for the 32bit libraries, to search
|
||||||
|
# for 64bit change x86/i686-w64 to x64/x86_64-w64
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2003-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# CMake - Cross Platform Makefile Generator
|
||||||
|
# Copyright 2000-2014 Kitware, Inc.
|
||||||
|
# Copyright 2000-2011 Insight Software Consortium
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||||
|
# nor the names of their contributors may be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
FIND_PATH(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_IMAGE}
|
||||||
|
PATH_SUFFIXES include/SDL2 include SDL2
|
||||||
|
i686-w64-mingw32/include/SDL2
|
||||||
|
x86_64-w64-mingw32/include/SDL2
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local/include/SDL2
|
||||||
|
/usr/include/SDL2
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
# Lookup the 64 bit libs on x64
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
FIND_LIBRARY(SDL2_IMAGE_LIBRARY_TEMP
|
||||||
|
NAMES SDL2_image
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_IMAGE}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
lib/x64
|
||||||
|
x86_64-w64-mingw32/lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
# On 32bit build find the 32bit libs
|
||||||
|
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
FIND_LIBRARY(SDL2_IMAGE_LIBRARY_TEMP
|
||||||
|
NAMES SDL2_image
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_IMAGE}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
lib/x86
|
||||||
|
i686-w64-mingw32/lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
||||||
|
SET(SDL2_IMAGE_FOUND "NO")
|
||||||
|
IF(SDL2_IMAGE_LIBRARY_TEMP)
|
||||||
|
# Set the final string here so the GUI reflects the final state.
|
||||||
|
SET(SDL2_IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARY_TEMP} CACHE STRING "Where the SDL2_image Library can be found")
|
||||||
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
|
SET(SDL2_IMAGE_LIBRARY_TEMP "${SDL2_IMAGE_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
SET(SDL2_IMAGE_FOUND "YES")
|
||||||
|
ENDIF(SDL2_IMAGE_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_IMAGE REQUIRED_VARS SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
# Locate SDL2_ttf library
|
||||||
|
# This module defines
|
||||||
|
# SDL2_TTF_LIBRARY, the name of the library to link against
|
||||||
|
# SDL2_TTF_FOUND, if false, do not try to link to SDL2_ttf
|
||||||
|
# SDL2_TTF_INCLUDE_DIR, where to find SDL_image.h
|
||||||
|
#
|
||||||
|
# Additional Note: If you see an empty SDL2_TTF_LIBRARY_TEMP in your configuration
|
||||||
|
# and no SDL2_TTF_LIBRARY, it means CMake did not find your SDL2_Image library
|
||||||
|
# (SDL2_ttf.dll, libsdl2_image.so, SDL2_ttf.framework, etc).
|
||||||
|
# Set SDL2_TTF_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
||||||
|
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
||||||
|
# as appropriate. These values are used to generate the final SDL2_TTF_LIBRARY
|
||||||
|
# variable, but when these values are unset, SDL2_TTF_LIBRARY does not get created.
|
||||||
|
#
|
||||||
|
# $SDL2 is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SDL2
|
||||||
|
# used in building SDL2.
|
||||||
|
# l.e.galup 9-20-02
|
||||||
|
#
|
||||||
|
# Modified by Eric Wing.
|
||||||
|
# Added code to assist with automated building by using environmental variables
|
||||||
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
# Added new modifications to recognize OS X frameworks and
|
||||||
|
# additional Unix paths (FreeBSD, etc).
|
||||||
|
# Also corrected the header search path to follow "proper" SDL2 guidelines.
|
||||||
|
# Added a search for SDL2main which is needed by some platforms.
|
||||||
|
# Added a search for threads which is needed by some platforms.
|
||||||
|
# Added needed compile switches for MinGW.
|
||||||
|
#
|
||||||
|
# On OSX, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SDL2_TTF_LIBRARY to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
#
|
||||||
|
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
|
||||||
|
# This needed to change because "proper" SDL2 convention
|
||||||
|
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
|
||||||
|
# reasons because not all systems place things in SDL2/ (see FreeBSD).
|
||||||
|
#
|
||||||
|
# Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake
|
||||||
|
# module with the minor edit of changing "SDL" to "SDL2" where necessary. This
|
||||||
|
# was not created for redistribution, and exists temporarily pending official
|
||||||
|
# SDL2 CMake modules.
|
||||||
|
#
|
||||||
|
# Note that on windows this will only search for the 32bit libraries, to search
|
||||||
|
# for 64bit change x86/i686-w64 to x64/x86_64-w64
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2003-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# CMake - Cross Platform Makefile Generator
|
||||||
|
# Copyright 2000-2014 Kitware, Inc.
|
||||||
|
# Copyright 2000-2011 Insight Software Consortium
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||||
|
# nor the names of their contributors may be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
FIND_PATH(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_TTF}
|
||||||
|
PATH_SUFFIXES include/SDL2 include SDL2
|
||||||
|
i686-w64-mingw32/include/SDL2
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local/include/SDL2
|
||||||
|
/usr/include/SDL2
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
# Lookup the 64 bit libs on x64
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
FIND_LIBRARY(SDL2_TTF_LIBRARY_TEMP
|
||||||
|
NAMES SDL2_ttf
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_TTF}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
lib/x64
|
||||||
|
x86_64-w64-mingw32/lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
# On 32bit build find the 32bit libs
|
||||||
|
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
FIND_LIBRARY(SDL2_TTF_LIBRARY_TEMP
|
||||||
|
NAMES SDL2_ttf
|
||||||
|
HINTS
|
||||||
|
${SDL2}
|
||||||
|
$ENV{SDL2}
|
||||||
|
$ENV{SDL2_TTF}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
lib/x86
|
||||||
|
i686-w64-mingw32/lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
||||||
|
SET(SDL2_TTF_FOUND "NO")
|
||||||
|
IF(SDL2_TTF_LIBRARY_TEMP)
|
||||||
|
# Set the final string here so the GUI reflects the final state.
|
||||||
|
SET(SDL2_TTF_LIBRARY ${SDL2_TTF_LIBRARY_TEMP} CACHE STRING "Where the SDL2_ttf Library can be found")
|
||||||
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
|
SET(SDL2_TTF_LIBRARY_TEMP "${SDL2_TTF_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
SET(SDL2_TTF_FOUND "YES")
|
||||||
|
ENDIF(SDL2_TTF_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_TTF REQUIRED_VARS SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
|
||||||
|
|
|
@ -7,5 +7,4 @@ if (MSYS AND (NOT MXE))
|
||||||
set(PLATFORM_OTHER 0)
|
set(PLATFORM_OTHER 0)
|
||||||
|
|
||||||
set(COLOBOT_CXX_FLAGS "${COLOBOT_CXX_FLAGS} -U__STRICT_ANSI__") # fixes putenv()
|
set(COLOBOT_CXX_FLAGS "${COLOBOT_CXX_FLAGS} -U__STRICT_ANSI__") # fixes putenv()
|
||||||
set(USE_SDL_MAIN 1) # fixes SDL_main
|
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -7,14 +7,9 @@ if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
||||||
set(PLATFORM_WINDOWS 1)
|
set(PLATFORM_WINDOWS 1)
|
||||||
set(PLATFORM_LINUX 0)
|
set(PLATFORM_LINUX 0)
|
||||||
set(PLATFORM_OTHER 0)
|
set(PLATFORM_OTHER 0)
|
||||||
# Because some tests will not compile
|
|
||||||
set(TESTS OFF)
|
|
||||||
# All must be static, CBOT and GLEW too
|
# All must be static, CBOT and GLEW too
|
||||||
set(CBOT_STATIC ON)
|
set(CBOT_STATIC ON)
|
||||||
set(GLEW_STATIC ON)
|
set(GLEW_STATIC ON)
|
||||||
# Because find package scripts are lame
|
|
||||||
set(SDLTTF_INCLUDE_DIR ${CMAKE_FIND_ROOT_PATH}/include/SDL)
|
|
||||||
set(SDLIMAGE_INCLUDE_DIR ${CMAKE_FIND_ROOT_PATH}/include/SDL)
|
|
||||||
|
|
||||||
if (${OPENAL_SOUND})
|
if (${OPENAL_SOUND})
|
||||||
set(OPENAL_MXE_LIBS
|
set(OPENAL_MXE_LIBS
|
||||||
|
@ -23,7 +18,6 @@ if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libvorbisenc.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libvorbisenc.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libvorbisfile.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libvorbisfile.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libogg.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libogg.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libwsock32.a
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -39,10 +33,18 @@ if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libwinmm.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libwinmm.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libdxguid.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libdxguid.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libbz2.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libbz2.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libimm32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libole32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/liboleaut32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libharfbuzz.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libwebp.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libversion.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libglib-2.0.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libwsock32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libws2_32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libintl.a
|
||||||
${OPENAL_MXE_LIBS}
|
${OPENAL_MXE_LIBS}
|
||||||
)
|
)
|
||||||
# This fixes problem with multiple definition of `IID_IDirectSoundNotify'
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition")
|
|
||||||
else()
|
else()
|
||||||
set(MXE 0)
|
set(MXE 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
2
data
2
data
|
@ -1 +1 @@
|
||||||
Subproject commit 14518ff47694de5bf13a5f43826187cf3d8e40a1
|
Subproject commit 90654ddfedb385d90d10db702264aa3c69c6afad
|
|
@ -6,7 +6,7 @@ colobot - educational programming strategy game
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] [B<-language> I<lang>]
|
B<colobot>
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -24,21 +24,107 @@ which can be used to program the robots available in the game.
|
||||||
|
|
||||||
Display a short help text
|
Display a short help text
|
||||||
|
|
||||||
|
=item B<-resolution> I<WxH>
|
||||||
|
|
||||||
|
Set runtime screen resolution
|
||||||
|
|
||||||
|
=item B<-graphics> I<default>|I<auto>|I<opengl>|I<gl14>|I<gl21>|I<gl33>
|
||||||
|
|
||||||
|
Changes graphics device
|
||||||
|
|
||||||
|
=item B<-glversion> I<default>|I<#.#>
|
||||||
|
|
||||||
|
Sets OpenGL context version to use.
|
||||||
|
|
||||||
|
=item B<-glprofile> I<default>|I<core>|I<compatibility>|I<opengles>
|
||||||
|
|
||||||
|
Sets OpenGL context profile to use.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 RUNTIME PATH OVERRIDES
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<-langdir> F</path/to/lang/>
|
||||||
|
|
||||||
|
Set custom language directory path
|
||||||
|
|
||||||
=item B<-datadir> F</path/to/data/>
|
=item B<-datadir> F</path/to/data/>
|
||||||
|
|
||||||
Set custom data directory path
|
Set custom data directory path
|
||||||
|
|
||||||
=item B<-debug>
|
=item B<-savedir> F</path/to/save/>
|
||||||
|
|
||||||
Enable debug mode (more info printed in logs)
|
Set custom save directory path (must be writable)
|
||||||
|
|
||||||
=item B<-loglevel> I<level>
|
=item B<-mod> F</path/to/mods/>
|
||||||
|
|
||||||
Set log level. Possible choices are: trace, debug, info, warn, error, none.
|
Set datadir mod path
|
||||||
|
|
||||||
=item B<-language> I<lang>
|
=back
|
||||||
|
|
||||||
Set language. Note that you can also fill the B<LANG> environment variable.
|
=head1 DEBUG OPTIONS
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<-loglevel> I<trace>|I<debug>|I<info>|I<warn>|I<error>|I<none>.
|
||||||
|
|
||||||
|
Set log level.
|
||||||
|
|
||||||
|
=item B<-debug> I<all>|I<event>|I<models>|...
|
||||||
|
|
||||||
|
Enable debug mode (more info printed in logs). Possible values are as follows, as well as any comma-separated combination
|
||||||
|
|
||||||
|
=over 10
|
||||||
|
|
||||||
|
=item sys_events
|
||||||
|
|
||||||
|
System events
|
||||||
|
|
||||||
|
=item update_events
|
||||||
|
|
||||||
|
Update events
|
||||||
|
|
||||||
|
=item app_events
|
||||||
|
|
||||||
|
Application events
|
||||||
|
|
||||||
|
=item events
|
||||||
|
|
||||||
|
All above events
|
||||||
|
|
||||||
|
=item models
|
||||||
|
|
||||||
|
Models-related debugging
|
||||||
|
|
||||||
|
=item all
|
||||||
|
|
||||||
|
All above debugging statements
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item B<-headless>
|
||||||
|
|
||||||
|
Run in headless mode - disables graphics, sound and user interaction
|
||||||
|
|
||||||
|
=item B<-runscene> I<scenecodename>
|
||||||
|
|
||||||
|
Run given scene on start (skip menus)
|
||||||
|
|
||||||
|
=item B<-scenetest>
|
||||||
|
|
||||||
|
Win every mission right after it's loaded
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 ENVIRONMENT
|
||||||
|
|
||||||
|
=over 6
|
||||||
|
|
||||||
|
=item LC_MESSAGES
|
||||||
|
|
||||||
|
Used to determine the runtime language.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2013-01-20 14:26+0100\n"
|
"POT-Creation-Date: 2016-03-25 19:24+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -16,16 +16,19 @@ msgstr ""
|
||||||
"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"
|
||||||
|
|
||||||
|
#. type: Name=
|
||||||
#: colobot.ini:1
|
#: colobot.ini:1
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Colobot"
|
msgid "Colobot"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: GenericName=
|
||||||
#: colobot.ini:2
|
#: colobot.ini:2
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Game to learn programming"
|
msgid "Game to learn programming"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: Comment=
|
||||||
#: colobot.ini:3
|
#: colobot.ini:3
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Colonize with bots"
|
msgid "Colonize with bots"
|
||||||
|
@ -48,9 +51,7 @@ msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:9
|
#: colobot.pod:9
|
||||||
msgid ""
|
msgid "B<colobot>"
|
||||||
"B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] "
|
|
||||||
"[B<-language> I<lang>]"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: =head1
|
#. type: =head1
|
||||||
|
@ -85,51 +86,227 @@ msgstr ""
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:27
|
#: colobot.pod:27
|
||||||
msgid "B<-datadir> F</path/to/data/>"
|
msgid "B<-resolution> I<WxH>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:29
|
#: colobot.pod:29
|
||||||
msgid "Set custom data directory path"
|
msgid "Set runtime screen resolution"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:31
|
#: colobot.pod:31
|
||||||
msgid "B<-debug>"
|
msgid "B<-graphics> I<default>|I<auto>|I<opengl>|I<gl14>|I<gl21>|I<gl33>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:33
|
#: colobot.pod:33
|
||||||
msgid "Enable debug mode (more info printed in logs)"
|
msgid "Changes graphics device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:35
|
#: colobot.pod:35
|
||||||
msgid "B<-loglevel> I<level>"
|
msgid "B<-glversion> I<default>|I<#.#>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:37
|
#: colobot.pod:37
|
||||||
msgid "Set log level. Possible choices are: trace, debug, info, warn, error, none."
|
msgid "Sets OpenGL context version to use."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:39
|
#: colobot.pod:39
|
||||||
msgid "B<-language> I<lang>"
|
msgid "B<-glprofile> I<default>|I<core>|I<compatibility>|I<opengles>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:41
|
#: colobot.pod:41
|
||||||
msgid "Set language. Note that you can also fill the B<LANG> environment variable."
|
msgid "Sets OpenGL context profile to use."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: =head1
|
#. type: =head1
|
||||||
#: colobot.pod:45
|
#: colobot.pod:45
|
||||||
|
msgid "RUNTIME PATH OVERRIDES"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:49
|
||||||
|
msgid "B<-langdir> F</path/to/lang/>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:51
|
||||||
|
msgid "Set custom language directory path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:53
|
||||||
|
msgid "B<-datadir> F</path/to/data/>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:55
|
||||||
|
msgid "Set custom data directory path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:57
|
||||||
|
msgid "B<-savedir> F</path/to/save/>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:59
|
||||||
|
msgid "Set custom save directory path (must be writable)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:61
|
||||||
|
msgid "B<-mod> F</path/to/mods/>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:63
|
||||||
|
msgid "Set datadir mod path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:67
|
||||||
|
msgid "DEBUG OPTIONS"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:71
|
||||||
|
msgid "B<-loglevel> I<trace>|I<debug>|I<info>|I<warn>|I<error>|I<none>."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:73
|
||||||
|
msgid "Set log level."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:75
|
||||||
|
msgid "B<-debug> I<all>|I<event>|I<models>|..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:77
|
||||||
|
msgid ""
|
||||||
|
"Enable debug mode (more info printed in logs). Possible values are as "
|
||||||
|
"follows, as well as any comma-separated combination"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:81
|
||||||
|
msgid "sys_events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:83
|
||||||
|
msgid "System events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:85
|
||||||
|
msgid "update_events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:87
|
||||||
|
msgid "Update events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:89
|
||||||
|
msgid "app_events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:91
|
||||||
|
msgid "Application events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:93
|
||||||
|
msgid "events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:95
|
||||||
|
msgid "All above events"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:97
|
||||||
|
msgid "models"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:99
|
||||||
|
msgid "Models-related debugging"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:101
|
||||||
|
msgid "all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:103
|
||||||
|
msgid "All above debugging statements"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:107
|
||||||
|
msgid "B<-headless>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:109
|
||||||
|
msgid "Run in headless mode - disables graphics, sound and user interaction"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:111
|
||||||
|
msgid "B<-runscene> I<scenecodename>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:113
|
||||||
|
msgid "Run given scene on start (skip menus)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:115
|
||||||
|
msgid "B<-scenetest>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:117
|
||||||
|
msgid "Win every mission right after it's loaded"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:121
|
||||||
|
msgid "ENVIRONMENT"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:125
|
||||||
|
msgid "LC_MESSAGES"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:127
|
||||||
|
msgid "Used to determine the runtime language."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:131
|
||||||
msgid "AUTHOR"
|
msgid "AUTHOR"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:47
|
#: colobot.pod:133
|
||||||
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
|
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
267
desktop/po/fr.po
267
desktop/po/fr.po
|
@ -1,31 +1,34 @@
|
||||||
# French translations for PACKAGE package
|
# French translations for Colobot package
|
||||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
# This file is distributed under the same license as the PACKAGE package.
|
# This file is distributed under the same license as the Colobot package.
|
||||||
#
|
#
|
||||||
# Didier Raboud <odyx@debian.org>, 2012.
|
# Didier Raboud <odyx@debian.org>, 2012, 2016.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: colobot 0.1.7\n"
|
||||||
"POT-Creation-Date: 2013-01-20 14:26+0100\n"
|
"POT-Creation-Date: 2016-03-25 19:24+0100\n"
|
||||||
"PO-Revision-Date: 2012-12-27 11:00+0100\n"
|
"PO-Revision-Date: 2016-03-25 21:13+0100\n"
|
||||||
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
|
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
|
||||||
"Language-Team: none\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"
|
||||||
|
|
||||||
|
#. type: Name=
|
||||||
#: colobot.ini:1
|
#: colobot.ini:1
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Colobot"
|
msgid "Colobot"
|
||||||
msgstr "Colobot"
|
msgstr "Colobot"
|
||||||
|
|
||||||
|
#. type: GenericName=
|
||||||
#: colobot.ini:2
|
#: colobot.ini:2
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Game to learn programming"
|
msgid "Game to learn programming"
|
||||||
msgstr "Apprentissage de la programmation par le jeu"
|
msgstr "Apprentissage de la programmation par le jeu"
|
||||||
|
|
||||||
|
#. type: Comment=
|
||||||
#: colobot.ini:3
|
#: colobot.ini:3
|
||||||
#, no-wrap
|
#, no-wrap
|
||||||
msgid "Colonize with bots"
|
msgid "Colonize with bots"
|
||||||
|
@ -48,12 +51,8 @@ msgstr "RÉSUMÉ"
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:9
|
#: colobot.pod:9
|
||||||
msgid ""
|
msgid "B<colobot>"
|
||||||
"B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] [B<-"
|
msgstr "B<colobot>"
|
||||||
"language> I<lang>]"
|
|
||||||
msgstr ""
|
|
||||||
"B<colobot> [B<-datadir> I<chemin>] [B<-debug>] [B<-loglevel> I<niveau>] [B<-"
|
|
||||||
"language> I<code-de-langue>]"
|
|
||||||
|
|
||||||
#. type: =head1
|
#. type: =head1
|
||||||
#: colobot.pod:11
|
#: colobot.pod:11
|
||||||
|
@ -93,61 +92,235 @@ msgstr "Affiche un court texte d'aide"
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:27
|
#: colobot.pod:27
|
||||||
|
msgid "B<-resolution> I<WxH>"
|
||||||
|
msgstr "B<-resolution> I<WxH>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:29
|
||||||
|
msgid "Set runtime screen resolution"
|
||||||
|
msgstr "Définit la résolution d'écran au lancement"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:31
|
||||||
|
msgid "B<-graphics> I<default>|I<auto>|I<opengl>|I<gl14>|I<gl21>|I<gl33>"
|
||||||
|
msgstr "B<-graphics> I<default>|I<auto>|I<opengl>|I<gl14>|I<gl21>|I<gl33>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:33
|
||||||
|
msgid "Changes graphics device"
|
||||||
|
msgstr "Change de périphérique graphique"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:35
|
||||||
|
msgid "B<-glversion> I<default>|I<#.#>"
|
||||||
|
msgstr "B<-glversion> I<default>|I<#.#>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:37
|
||||||
|
msgid "Sets OpenGL context version to use."
|
||||||
|
msgstr "Définit la version du contexte OpenGL à utiliser."
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:39
|
||||||
|
msgid "B<-glprofile> I<default>|I<core>|I<compatibility>|I<opengles>"
|
||||||
|
msgstr "B<-glprofile> I<default>|I<core>|I<compatibility>|I<opengles>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:41
|
||||||
|
msgid "Sets OpenGL context profile to use."
|
||||||
|
msgstr "Définit le profil de context OpenGL à utiliser."
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:45
|
||||||
|
msgid "RUNTIME PATH OVERRIDES"
|
||||||
|
msgstr "SURCHARGES DE CHEMINS AU LANCEMENT"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:49
|
||||||
|
msgid "B<-langdir> F</path/to/lang/>"
|
||||||
|
msgstr "B<-langdir> F</chemin/vers/lang/>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:51
|
||||||
|
msgid "Set custom language directory path"
|
||||||
|
msgstr "Définit le chemin vers un répertoire de fichiers de traductions"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:53
|
||||||
msgid "B<-datadir> F</path/to/data/>"
|
msgid "B<-datadir> F</path/to/data/>"
|
||||||
msgstr "B<-datadir> F</chemin/vers/les/donnes/>"
|
msgstr "B<-datadir> F</chemin/vers/les/donnes/>"
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:29
|
#: colobot.pod:55
|
||||||
msgid "Set custom data directory path"
|
msgid "Set custom data directory path"
|
||||||
msgstr "Définit le chemin vers un répertoire de données spécifique"
|
msgstr "Définit le chemin vers un répertoire de données spécifique"
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:31
|
#: colobot.pod:57
|
||||||
msgid "B<-debug>"
|
msgid "B<-savedir> F</path/to/save/>"
|
||||||
msgstr "B<-debug>"
|
msgstr "B<-savedir> F</chemin/vers/save/>"
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:33
|
#: colobot.pod:59
|
||||||
msgid "Enable debug mode (more info printed in logs)"
|
msgid "Set custom save directory path (must be writable)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Active le mode de déboguage (plus d'informations sont affichées dans le "
|
"Définit le chemin vers le répertoire de sauvegardes (doit être inscriptible)"
|
||||||
"journal)"
|
|
||||||
|
|
||||||
#. type: =item
|
#. type: =item
|
||||||
#: colobot.pod:35
|
#: colobot.pod:61
|
||||||
msgid "B<-loglevel> I<level>"
|
msgid "B<-mod> F</path/to/mods/>"
|
||||||
msgstr "B<-loglevel> I<niveau>"
|
msgstr "B<-mod> F</chemin/vers/mods/>"
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:37
|
#: colobot.pod:63
|
||||||
msgid ""
|
msgid "Set datadir mod path"
|
||||||
"Set log level. Possible choices are: trace, debug, info, warn, error, none."
|
msgstr "Définit le chemin vers un répertoire de mods spécifiques"
|
||||||
msgstr ""
|
|
||||||
"Définit le niveau de journalisation parmi: trace, debug, info, warn, error, "
|
|
||||||
"none."
|
|
||||||
|
|
||||||
#. type: =item
|
|
||||||
#: colobot.pod:39
|
|
||||||
msgid "B<-language> I<lang>"
|
|
||||||
msgstr "B<-language> I<langue>"
|
|
||||||
|
|
||||||
#. type: textblock
|
|
||||||
#: colobot.pod:41
|
|
||||||
msgid ""
|
|
||||||
"Set language. Note that you can also fill the B<LANG> environment variable."
|
|
||||||
msgstr ""
|
|
||||||
"Définit la langue. Il est aussi possible d'utiliser la variable "
|
|
||||||
"d'environnement B<LANG>."
|
|
||||||
|
|
||||||
#. type: =head1
|
#. type: =head1
|
||||||
#: colobot.pod:45
|
#: colobot.pod:67
|
||||||
|
msgid "DEBUG OPTIONS"
|
||||||
|
msgstr "OPTIONS DE DEBUG"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:71
|
||||||
|
msgid "B<-loglevel> I<trace>|I<debug>|I<info>|I<warn>|I<error>|I<none>."
|
||||||
|
msgstr "B<-loglevel> I<trace>|I<debug>|I<info>|I<warn>|I<error>|I<none>."
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:73
|
||||||
|
msgid "Set log level."
|
||||||
|
msgstr "Définit le niveau de log"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:75
|
||||||
|
msgid "B<-debug> I<all>|I<event>|I<models>|..."
|
||||||
|
msgstr "B<-debug> I<all>|I<event>|I<models>|..."
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:77
|
||||||
|
msgid ""
|
||||||
|
"Enable debug mode (more info printed in logs). Possible values are as "
|
||||||
|
"follows, as well as any comma-separated combination"
|
||||||
|
msgstr ""
|
||||||
|
"Active le mode de I<debug> (plus d'informations dans les logs). Les valeurs"
|
||||||
|
" possibles sont les suivantes, ainsi que toute combinaison séparée par des"
|
||||||
|
" virgules"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:81
|
||||||
|
msgid "sys_events"
|
||||||
|
msgstr "sys_events"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:83
|
||||||
|
msgid "System events"
|
||||||
|
msgstr "Événements système"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:85
|
||||||
|
msgid "update_events"
|
||||||
|
msgstr "update_events"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:87
|
||||||
|
msgid "Update events"
|
||||||
|
msgstr "Événements de mise à jour"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:89
|
||||||
|
msgid "app_events"
|
||||||
|
msgstr "app_events"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:91
|
||||||
|
msgid "Application events"
|
||||||
|
msgstr "Événements de l'application"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:93
|
||||||
|
msgid "events"
|
||||||
|
msgstr "events"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:95
|
||||||
|
msgid "All above events"
|
||||||
|
msgstr "Tous les événements ci-dessus"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:97
|
||||||
|
msgid "models"
|
||||||
|
msgstr "models"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:99
|
||||||
|
msgid "Models-related debugging"
|
||||||
|
msgstr "Debug pour les modèles"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:101
|
||||||
|
msgid "all"
|
||||||
|
msgstr "all"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:103
|
||||||
|
msgid "All above debugging statements"
|
||||||
|
msgstr "Tout les messages de debug ci-dessus"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:107
|
||||||
|
msgid "B<-headless>"
|
||||||
|
msgstr "B<-headless>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:109
|
||||||
|
msgid "Run in headless mode - disables graphics, sound and user interaction"
|
||||||
|
msgstr ""
|
||||||
|
"Lance en mode I<headless> - désactive les graphiques, sons et interactions"
|
||||||
|
" utilisateurs"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:111
|
||||||
|
msgid "B<-runscene> I<scenecodename>"
|
||||||
|
msgstr "B<-runscene> I<scenecodename>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:113
|
||||||
|
msgid "Run given scene on start (skip menus)"
|
||||||
|
msgstr "Lance une scène donnée au lancement (saute les menus)"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:115
|
||||||
|
msgid "B<-scenetest>"
|
||||||
|
msgstr "B<-scenetest>"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:117
|
||||||
|
msgid "Win every mission right after it's loaded"
|
||||||
|
msgstr "Gagne chaque mission immédiatement après son lancement"
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:121
|
||||||
|
msgid "ENVIRONMENT"
|
||||||
|
msgstr "ENVIRONNEMENT"
|
||||||
|
|
||||||
|
#. type: =item
|
||||||
|
#: colobot.pod:125
|
||||||
|
msgid "LC_MESSAGES"
|
||||||
|
msgstr "LC_MESSAGES"
|
||||||
|
|
||||||
|
#. type: textblock
|
||||||
|
#: colobot.pod:127
|
||||||
|
msgid "Used to determine the runtime language."
|
||||||
|
msgstr "Utilisé pour déterminer la langue au lancement"
|
||||||
|
|
||||||
|
#. type: =head1
|
||||||
|
#: colobot.pod:131
|
||||||
msgid "AUTHOR"
|
msgid "AUTHOR"
|
||||||
msgstr "Auteur"
|
msgstr "Auteur"
|
||||||
|
|
||||||
#. type: textblock
|
#. type: textblock
|
||||||
#: colobot.pod:47
|
#: colobot.pod:133
|
||||||
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
|
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Cette page de manuel a été écrite et traduite par Didier Raboud "
|
"Cette page de manuel a été écrite et traduite par Didier 'OdyX' Raboud "
|
||||||
"<S<odyx@debian.org>>."
|
"<S<odyx@debian.org>>."
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
libclipboard.a
|
|
|
@ -1,18 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
include_directories(. include/clipboard)
|
|
||||||
|
|
||||||
add_definitions(-DLIB_COMPILE=1)
|
|
||||||
|
|
||||||
|
|
||||||
if(PLATFORM_WINDOWS)
|
|
||||||
set(CLIPBOARD_SRC src/clipboardWin32.c)
|
|
||||||
elseif(PLATFORM_MACOSX)
|
|
||||||
set(CMAKE_CXX_FLAGS "-fobjc-arc")
|
|
||||||
set(CLIPBOARD_SRC src/clipboardOSX.m)
|
|
||||||
else()
|
|
||||||
set(CLIPBOARD_SRC src/clipboardX11.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(${SDL_INCLUDE_DIR})
|
|
||||||
add_library(clipboard STATIC src/utf.c ${CLIPBOARD_SRC})
|
|
|
@ -1,72 +0,0 @@
|
||||||
Warzone 2100 Source & Data
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
This document replaces the file "readme.txt" as present in the Warzone 2100 GPL
|
|
||||||
release of December 6th 2004.
|
|
||||||
|
|
||||||
1) These source and data files are provided as is with no guarantees:
|
|
||||||
- No assistance or support will be offered or given.
|
|
||||||
- Everything you will require to make a build of the game should be here. If
|
|
||||||
it isn't, you'll have to improvise.
|
|
||||||
- None of us here at Pivotal Games are in a position to be able to offer any
|
|
||||||
help with making this work.
|
|
||||||
|
|
||||||
2) Everything included (source code and data), as well as the not included
|
|
||||||
videos and music, is released under the terms of the GNU General Public
|
|
||||||
License, version 2 or (at your option) any later version.
|
|
||||||
Please be sure to read the entirety of this license, but the summary is that
|
|
||||||
you're free to do what you want with the source subject to making the full
|
|
||||||
source code freely available in the event of the distribution of new
|
|
||||||
binaries.
|
|
||||||
|
|
||||||
3) Following exception to the GPL is granted:
|
|
||||||
------
|
|
||||||
Linking Warzone 2100 statically or dynamically with other modules is making
|
|
||||||
a combined work based on Warzone 2100. Thus, the terms and conditions of
|
|
||||||
the GNU General Public License cover the whole combination.
|
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders of Warzone 2100
|
|
||||||
give you permission to combine Warzone 2100 with code included in the
|
|
||||||
standard release of libraries that are accessible, redistributable and
|
|
||||||
linkable free of charge. You may copy and distribute such a system
|
|
||||||
following the terms of the GNU GPL for Warzone 2100 and the licenses of the
|
|
||||||
other code concerned.
|
|
||||||
|
|
||||||
Note that people who make modified versions of Warzone 2100 are not
|
|
||||||
obligated to grant this special exception for their modified versions; it
|
|
||||||
is their choice whether to do so. The GNU General Public License gives
|
|
||||||
permission to release a modified version without this exception; this
|
|
||||||
exception also makes it possible to release a modified version which
|
|
||||||
carries forward this exception.
|
|
||||||
------
|
|
||||||
|
|
||||||
4) Permission is granted to use the name "Warzone 2100", the logos, stories,
|
|
||||||
texts and related materials.
|
|
||||||
|
|
||||||
5) Permission is granted to copy and distribute unaltered copies and/or images
|
|
||||||
of the original game discs in any medium, provided that they are distributed
|
|
||||||
free of charge and retain their original copyright and trademark notices.
|
|
||||||
|
|
||||||
Finally, the primary motivation for this release is for entertainment and
|
|
||||||
educational purposes. On the subject of the latter, don't be surprised to see
|
|
||||||
some pretty gnarly old-school C code in here; the game was a classic, but large
|
|
||||||
areas of the code aren't pretty; OO design and C++ evangelists beware! We
|
|
||||||
haven't spent any time cleaning the code or making it pretty - what you see is
|
|
||||||
what you're getting, warts n' all.
|
|
||||||
|
|
||||||
Thank you to Jonathan Kemp of Eidos Europe for permitting the release. Thanks to
|
|
||||||
Martin Severn for allowing to use his soundtrack. Thanks to Jason Walker for
|
|
||||||
helping to facilitate the release of the movies and sound tracks, as well as
|
|
||||||
clarifying the meaning of this license. Thanks also to Frank Lamboy for
|
|
||||||
assistance with the release and for campaigning along with many many others
|
|
||||||
over the years for the source to be made available.
|
|
||||||
The correspondence, online petitions and persistence made this possible. We were
|
|
||||||
constantly amazed at the community support for Warzone even after all this
|
|
||||||
time; it's nice to be able to give something back, assuming you can get it to
|
|
||||||
compile... ;-)
|
|
||||||
|
|
||||||
Original - 6th December 2004
|
|
||||||
Alex M - ex Pumpkin Studios (Eidos)
|
|
||||||
|
|
||||||
Amended - 10th June 2008
|
|
||||||
Jason W - Eidos
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 2008 Freddie Witherden
|
|
||||||
Copyright (C) 2008-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CLIPBOARD_H_
|
|
||||||
#define CLIPBOARD_H_
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a copy of the text in the systems clipboard. Should the clipboard be
|
|
||||||
* empty, or populated with non-textual data NULL is returned. The character set
|
|
||||||
* of the returned is guaranteed to be UTF-8.
|
|
||||||
*
|
|
||||||
* It remains the responsibility of the caller to free() the string when
|
|
||||||
* finished with it.
|
|
||||||
*
|
|
||||||
* @return The textual contents of the clipboard (if any), otherwise NULL.
|
|
||||||
*/
|
|
||||||
char *widgetGetClipboardText(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to set the contents of the systems clipboard to text. The character
|
|
||||||
* set of text must be UTF-8.
|
|
||||||
*
|
|
||||||
* @param text The UTF-8 text to set the clipboard to.
|
|
||||||
* @return True if the contents were successfully set, false otherwise.
|
|
||||||
*/
|
|
||||||
bool widgetSetClipboardText(const char *text);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*CLIPBOARD_H_*/
|
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 1999-2004 Eidos Interactive
|
|
||||||
Copyright (C) 2005-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
/*! \file
|
|
||||||
* \brief Simple type definitions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __INCLUDED_LIB_FRAMEWORK_TYPES_H__
|
|
||||||
#define __INCLUDED_LIB_FRAMEWORK_TYPES_H__
|
|
||||||
|
|
||||||
#include "wzglobal.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_INTTYPES_H // defined WZ_C99
|
|
||||||
/* Compilers that have support for C99 have all values below defined in stdint.h */
|
|
||||||
# include <inttypes.h>
|
|
||||||
#else
|
|
||||||
// Defines C99 types for C99 incompatible compilers (e.g. MSVC)
|
|
||||||
#include <SDL_stdinc.h>
|
|
||||||
#ifndef WZ_CC_MINGW
|
|
||||||
# define INT8_MIN (-128)
|
|
||||||
# define INT16_MIN (-32767-1)
|
|
||||||
# define INT32_MIN (-2147483647-1)
|
|
||||||
# define INT8_MAX (127)
|
|
||||||
# define INT16_MAX (32767)
|
|
||||||
# define INT32_MAX (2147483647)
|
|
||||||
# define UINT8_MAX (255)
|
|
||||||
# define UINT16_MAX (65535)
|
|
||||||
# define UINT32_MAX (4294967295U)
|
|
||||||
#endif
|
|
||||||
#ifdef WZ_CC_MSVC
|
|
||||||
# define PRIu32 "u"
|
|
||||||
# define PRIu64 "I64u"
|
|
||||||
typedef SSIZE_T ssize_t;
|
|
||||||
#endif
|
|
||||||
#endif // WZ_C99
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/* Basic numeric types */
|
|
||||||
typedef uint8_t UBYTE;
|
|
||||||
typedef int8_t SBYTE;
|
|
||||||
typedef uint16_t UWORD;
|
|
||||||
typedef int16_t SWORD;
|
|
||||||
typedef uint32_t UDWORD;
|
|
||||||
typedef int32_t SDWORD;
|
|
||||||
|
|
||||||
/* Numeric size defines */
|
|
||||||
#define UBYTE_MAX UINT8_MAX
|
|
||||||
#define SBYTE_MIN INT8_MIN
|
|
||||||
#define SBYTE_MAX INT8_MAX
|
|
||||||
#define UWORD_MAX UINT16_MAX
|
|
||||||
#define SWORD_MIN INT16_MIN
|
|
||||||
#define SWORD_MAX INT16_MAX
|
|
||||||
#define UDWORD_MAX UINT32_MAX
|
|
||||||
#define SDWORD_MIN INT32_MIN
|
|
||||||
#define SDWORD_MAX INT32_MAX
|
|
||||||
|
|
||||||
// If we are C99 compatible, the "bool" macro will be defined in <stdbool.h> (as _Bool)
|
|
||||||
// C++ comes with an integrated bool type
|
|
||||||
#if defined(WZ_CXX98)
|
|
||||||
#elif defined(WZ_C99)
|
|
||||||
# include <stdbool.h>
|
|
||||||
#else
|
|
||||||
// Pretend we are C99 compatible (well, for the bool type then)
|
|
||||||
# ifndef bool
|
|
||||||
# define bool BOOL
|
|
||||||
# endif
|
|
||||||
# ifndef true
|
|
||||||
# define true (1)
|
|
||||||
# endif
|
|
||||||
# ifndef false
|
|
||||||
# define false (0)
|
|
||||||
# endif
|
|
||||||
# ifndef __bool_true_false_are_defined
|
|
||||||
# define __bool_true_false_are_defined (1)
|
|
||||||
# endif
|
|
||||||
#endif /* WZ_C99 */
|
|
||||||
|
|
||||||
#if !defined(WZ_OS_WIN)
|
|
||||||
typedef int BOOL;
|
|
||||||
#endif // WZ_OS_WIN
|
|
||||||
|
|
||||||
#endif // __INCLUDED_LIB_FRAMEWORK_TYPES_H__
|
|
|
@ -1,115 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 2007 Giel van Schijndel
|
|
||||||
Copyright (C) 2007-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
$Revision: 9336 $
|
|
||||||
$Id: utf.h 9336 2010-01-18 19:10:17Z cypr $
|
|
||||||
$HeadURL: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk/lib/framework/utf.h $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __INCLUDE_LIB_FRAMEWORK_UTF8_H__
|
|
||||||
#define __INCLUDE_LIB_FRAMEWORK_UTF8_H__
|
|
||||||
|
|
||||||
/* Allow frame header files to be singly included */
|
|
||||||
#define FRAME_LIB_INCLUDE
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif //__cplusplus
|
|
||||||
|
|
||||||
/** Used to store a UTF-32 character in
|
|
||||||
*/
|
|
||||||
typedef uint32_t utf_32_char;
|
|
||||||
|
|
||||||
/** Used to store a UTF-16 character in (this is <em>not</em> necessarily a
|
|
||||||
* full Unicode codepoint)
|
|
||||||
*/
|
|
||||||
typedef uint16_t utf_16_char;
|
|
||||||
|
|
||||||
/** Decodes a single Unicode character from the given UTF-16 string.
|
|
||||||
*
|
|
||||||
* \param utf16_char Points to a character string that should contain at
|
|
||||||
* least one valid UTF-16 character sequence.
|
|
||||||
* \param[out] next_char Will be modified to point to the first character
|
|
||||||
* following the UTF-16 character sequence.
|
|
||||||
*
|
|
||||||
* \return The Unicode character encoded as UTF-32 with native endianness.
|
|
||||||
*/
|
|
||||||
utf_32_char UTF16DecodeChar(const utf_16_char *utf16_char, const utf_16_char **next_char);
|
|
||||||
|
|
||||||
/** Decodes a single Unicode character from the given UTF-8 string.
|
|
||||||
*
|
|
||||||
* \param utf8_char Points to a character string that should contain at
|
|
||||||
* least one valid UTF-8 character sequence.
|
|
||||||
* \param[out] next_char Will be modified to point to the first character
|
|
||||||
* following the UTF-8 character sequence.
|
|
||||||
*
|
|
||||||
* \return The Unicode character encoded as UTF-32 with native endianness.
|
|
||||||
*/
|
|
||||||
utf_32_char UTF8DecodeChar(const char *utf8_char, const char **next_char);
|
|
||||||
|
|
||||||
/** Determines the amount of unicode codepoints in a UTF-8 encoded string
|
|
||||||
* \param utf8_string the UTF-8 encoded string to count
|
|
||||||
* \return the amount of codepoints found in the UTF-8 string
|
|
||||||
*/
|
|
||||||
size_t UTF8CharacterCount(const char *utf8_string);
|
|
||||||
|
|
||||||
size_t UTF16CharacterCount(const uint16_t *utf16);
|
|
||||||
|
|
||||||
/** Encodes a UTF-16 encoded unicode string to a UTF-8 encoded string
|
|
||||||
* \param unicode_string the UTF-16 encoded unicode string to encode into UTF-8
|
|
||||||
* \param[out] nbytes the number of bytes allocated, may be NULL
|
|
||||||
* \return a UTF-8 encoded unicode nul terminated string (use free() to deallocate it)
|
|
||||||
*/
|
|
||||||
char *UTF16toUTF8(const utf_16_char *unicode_string, size_t *nbytes);
|
|
||||||
|
|
||||||
/** Decodes a UTF-8 encoded string to a UTF-16 encoded string (native endianess)
|
|
||||||
* \param utf8_string a UTF-8 encoded nul terminated string
|
|
||||||
* \param[out] nbytes the number of bytes allocated, may be NULL
|
|
||||||
* \return a UTF-16 encoded unicode nul terminated string (use free() to deallocate it)
|
|
||||||
*/
|
|
||||||
utf_16_char *UTF8toUTF16(const char *utf8_string, size_t *nbytes);
|
|
||||||
|
|
||||||
char *UTF8CharacterAtOffset(const char *utf8_string, size_t index);
|
|
||||||
utf_16_char *UTF16CharacterAtOffset(const utf_16_char *utf16_string, size_t index);
|
|
||||||
|
|
||||||
/** Encodes a UTF-32 string to a UTF-8 encoded string
|
|
||||||
* \param unicode_string the UTF-32 string to encode into UTF-8
|
|
||||||
* \param[out] nbytes the number of bytes allocated, may be NULL
|
|
||||||
* \return a UTF-8 encoded unicode nul terminated string (use free() to deallocate it)
|
|
||||||
*/
|
|
||||||
char *UTF32toUTF8(const utf_32_char *unicode_string, size_t *nbytes);
|
|
||||||
|
|
||||||
/** Decodes a UTF-8 encoded string to a UTF-32 string
|
|
||||||
* \param utf8_string a UTF-8 encoded nul terminated string
|
|
||||||
* \param[out] nbytes the number of bytes allocated, may be NULL
|
|
||||||
* \return a UTF-32 nul terminated string (use free() to deallocate it)
|
|
||||||
*/
|
|
||||||
utf_32_char *UTF8toUTF32(const char *utf8_string, size_t *nbytes);
|
|
||||||
|
|
||||||
/** Returns number of characters, not including terminating nul. */
|
|
||||||
size_t utf32len(const utf_32_char *unicode_string);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif //__cplusplus
|
|
||||||
|
|
||||||
#endif // __INCLUDE_LIB_FRAMEWORK_UTF8_H__
|
|
|
@ -1,614 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 1992-2007 Trolltech ASA.
|
|
||||||
Copyright (C) 2005-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
/*! \file wzglobal.h
|
|
||||||
* \brief Platform detection, workarounds and compat fixes
|
|
||||||
*
|
|
||||||
* OS and CC detection code shamelessly stolen from Qt4 (Qt/qglobal.h) by Dennis.
|
|
||||||
* This has been stripped down, feel free to add checks as you need them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WZGLOBAL_H
|
|
||||||
#define WZGLOBAL_H
|
|
||||||
|
|
||||||
#ifndef __STDC_FORMAT_MACROS
|
|
||||||
#define __STDC_FORMAT_MACROS
|
|
||||||
#endif
|
|
||||||
#ifndef __STDC_LIMIT_MACROS
|
|
||||||
#define __STDC_LIMIT_MACROS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_CONFIG_H)
|
|
||||||
# undef _XOPEN_SOURCE
|
|
||||||
# include "config.h"
|
|
||||||
#elif defined(__MACOSX__)
|
|
||||||
# include "config-macosx.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ---- Platform detection ---- */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The operating system, must be one of: (WZ_OS_x)
|
|
||||||
|
|
||||||
DARWIN - Darwin OS (synonym for WZ_OS_MAC)
|
|
||||||
OS2 - OS/2
|
|
||||||
OS2EMX - XFree86 on OS/2 (not PM)
|
|
||||||
WIN32 - Win32 (Windows 95/98/ME and Windows NT/2000/XP)
|
|
||||||
CYGWIN - Cygwin
|
|
||||||
SOLARIS - Sun Solaris
|
|
||||||
HPUX - HP-UX
|
|
||||||
ULTRIX - DEC Ultrix
|
|
||||||
LINUX - Linux
|
|
||||||
FREEBSD - FreeBSD
|
|
||||||
GNU_kFREEBSD - GNU/kFreeBSD
|
|
||||||
NETBSD - NetBSD
|
|
||||||
OPENBSD - OpenBSD
|
|
||||||
BSDI - BSD/OS
|
|
||||||
IRIX - SGI Irix
|
|
||||||
OSF - HP Tru64 UNIX
|
|
||||||
SCO - SCO OpenServer 5
|
|
||||||
UNIXWARE - UnixWare 7, Open UNIX 8
|
|
||||||
AIX - AIX
|
|
||||||
HURD - GNU Hurd
|
|
||||||
DGUX - DG/UX
|
|
||||||
RELIANT - Reliant UNIX
|
|
||||||
DYNIX - DYNIX/ptx
|
|
||||||
QNX - QNX
|
|
||||||
QNX6 - QNX RTP 6.1
|
|
||||||
LYNX - LynxOS
|
|
||||||
BSD4 - Any BSD 4.4 system
|
|
||||||
UNIX - Any UNIX BSD/SYSV system
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
|
|
||||||
# define WZ_OS_DARWIN
|
|
||||||
# define WZ_OS_BSD4
|
|
||||||
# ifdef __LP64__
|
|
||||||
# define WZ_OS_DARWIN64
|
|
||||||
# else
|
|
||||||
# define WZ_OS_DARWIN32
|
|
||||||
# endif
|
|
||||||
#elif defined(__CYGWIN__)
|
|
||||||
# define WZ_OS_CYGWIN
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
# if defined(__EMX__)
|
|
||||||
# define WZ_OS_OS2EMX
|
|
||||||
# else
|
|
||||||
# define WZ_OS_OS2
|
|
||||||
# endif
|
|
||||||
#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
|
|
||||||
# define WZ_OS_WIN32
|
|
||||||
# define WZ_OS_WIN64
|
|
||||||
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
|
|
||||||
# define WZ_OS_WIN32
|
|
||||||
#elif defined(__MWERKS__) && defined(__INTEL__)
|
|
||||||
# define WZ_OS_WIN32
|
|
||||||
#elif defined(__sun) || defined(sun)
|
|
||||||
# define WZ_OS_SOLARIS
|
|
||||||
#elif defined(hpux) || defined(__hpux)
|
|
||||||
# define WZ_OS_HPUX
|
|
||||||
#elif defined(__ultrix) || defined(ultrix)
|
|
||||||
# define WZ_OS_ULTRIX
|
|
||||||
#elif defined(sinix)
|
|
||||||
# define WZ_OS_RELIANT
|
|
||||||
#elif defined(__linux__) || defined(__linux)
|
|
||||||
# define WZ_OS_LINUX
|
|
||||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
# define WZ_OS_FREEBSD
|
|
||||||
# define WZ_OS_BSD4
|
|
||||||
#elif defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)
|
|
||||||
/* We're running a non-FreeBSD system with a FreeBSD kernel. Find out what C
|
|
||||||
* library we're using to detect the system we're running on. */
|
|
||||||
# include <stdlib.h>
|
|
||||||
# if defined(__GLIBC__)
|
|
||||||
/* We're running GNU/kFreeBSD */
|
|
||||||
# define WZ_OS_GNU_kFREEBSD
|
|
||||||
# endif
|
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
# define WZ_OS_NETBSD
|
|
||||||
# define WZ_OS_BSD4
|
|
||||||
#elif defined(__OpenBSD__)
|
|
||||||
# define WZ_OS_OPENBSD
|
|
||||||
# define WZ_OS_BSD4
|
|
||||||
#elif defined(__bsdi__)
|
|
||||||
# define WZ_OS_BSDI
|
|
||||||
# define WZ_OS_BSD4
|
|
||||||
#elif defined(__sgi)
|
|
||||||
# define WZ_OS_IRIX
|
|
||||||
#elif defined(__osf__)
|
|
||||||
# define WZ_OS_OSF
|
|
||||||
#elif defined(_AIX)
|
|
||||||
# define WZ_OS_AIX
|
|
||||||
#elif defined(__Lynx__)
|
|
||||||
# define WZ_OS_LYNX
|
|
||||||
#elif defined(__GNU__)
|
|
||||||
# define WZ_OS_HURD
|
|
||||||
#elif defined(__DGUX__)
|
|
||||||
# define WZ_OS_DGUX
|
|
||||||
#elif defined(__QNXNTO__)
|
|
||||||
# define WZ_OS_QNX6
|
|
||||||
#elif defined(__QNX__)
|
|
||||||
# define WZ_OS_QNX
|
|
||||||
#elif defined(_SEQUENT_)
|
|
||||||
# define WZ_OS_DYNIX
|
|
||||||
#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */
|
|
||||||
# define WZ_OS_SCO
|
|
||||||
#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */
|
|
||||||
# define WZ_OS_UNIXWARE
|
|
||||||
#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */
|
|
||||||
# define WZ_OS_UNIXWARE
|
|
||||||
#elif defined(__INTEGRITY)
|
|
||||||
# define WZ_OS_INTEGRITY
|
|
||||||
#elif defined(__MAKEDEPEND__)
|
|
||||||
#else
|
|
||||||
# error "Warzone has not been tested on this OS. Please contact warzone-dev@gna.org"
|
|
||||||
#endif /* WZ_OS_x */
|
|
||||||
|
|
||||||
#if defined(WZ_OS_WIN32) || defined(WZ_OS_WIN64)
|
|
||||||
# define WZ_OS_WIN
|
|
||||||
#endif /* WZ_OS_WIN32 */
|
|
||||||
|
|
||||||
#if defined(WZ_OS_DARWIN)
|
|
||||||
# define WZ_OS_MAC /* WZ_OS_MAC is mostly for compatibility, but also more clear */
|
|
||||||
# define WZ_OS_MACX /* WZ_OS_MACX is only for compatibility.*/
|
|
||||||
# if defined(WZ_OS_DARWIN64)
|
|
||||||
# define WZ_OS_MAC64
|
|
||||||
# elif defined(WZ_OS_DARWIN32)
|
|
||||||
# define WZ_OS_MAC32
|
|
||||||
# endif
|
|
||||||
#endif /* WZ_OS_DARWIN */
|
|
||||||
|
|
||||||
#if defined(WZ_OS_MSDOS) || defined(WZ_OS_OS2) || defined(WZ_OS_WIN)
|
|
||||||
# undef WZ_OS_UNIX
|
|
||||||
#elif !defined(WZ_OS_UNIX)
|
|
||||||
# define WZ_OS_UNIX
|
|
||||||
#endif /* WZ_OS_* */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The compiler, must be one of: (WZ_CC_x)
|
|
||||||
|
|
||||||
MSVC - Microsoft Visual C/C++, Intel C++ for Windows
|
|
||||||
GNU - GNU C++
|
|
||||||
CLANG - Clang LLVM
|
|
||||||
INTEL - Intel C++ for Linux, Intel C++ for Windows
|
|
||||||
TINYC - Fabrice Bellard's Tiny C Compiler
|
|
||||||
|
|
||||||
Should be sorted most to least authoritative.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
# define WZ_CC_MSVC
|
|
||||||
/* All ISO C89 compliant compilers _should_ define the macro __STDC__, MSVC
|
|
||||||
* however is known _not_ to do this, so work around that here. */
|
|
||||||
# if !defined(__STDC__)
|
|
||||||
# define __STDC__ 1
|
|
||||||
# endif
|
|
||||||
/* Visual C++.Net issues for _MSC_VER >= 1300 */
|
|
||||||
# if _MSC_VER >= 1300
|
|
||||||
# define WZ_CC_MSVC_NET
|
|
||||||
# endif
|
|
||||||
/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
|
|
||||||
# if defined(__INTEL_COMPILER)
|
|
||||||
# define WZ_CC_INTEL
|
|
||||||
# endif
|
|
||||||
/* x64 does not support mmx intrinsics on windows */
|
|
||||||
# if (defined(ZS_OS_WIN64) && defined(_M_X64))
|
|
||||||
# undef ZS_HAVE_SSE
|
|
||||||
# undef ZS_HAVE_SSE2
|
|
||||||
# undef ZS_HAVE_MMX
|
|
||||||
# undef ZS_HAVE_3DNOW
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
# define WZ_CC_GNU
|
|
||||||
# if defined(__MINGW32__)
|
|
||||||
# define WZ_CC_MINGW
|
|
||||||
# endif
|
|
||||||
# if defined(__INTEL_COMPILER)
|
|
||||||
/* Intel C++ also masquerades as GCC 3.2.0 */
|
|
||||||
# define WZ_CC_INTEL
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(__llvm__)
|
|
||||||
# define WZ_CC_LLVM
|
|
||||||
# endif
|
|
||||||
# if defined(__clang__)
|
|
||||||
# define WZ_CC_CLANG
|
|
||||||
# endif
|
|
||||||
/* Clang may not always masquerade as gcc */
|
|
||||||
#elif defined(__clang__)
|
|
||||||
# define WZ_CC_CLANG
|
|
||||||
# define WZ_CC_LLVM
|
|
||||||
|
|
||||||
#elif defined(__TINYC__)
|
|
||||||
# define WZ_CC_TINYC
|
|
||||||
|
|
||||||
#else
|
|
||||||
# error "Warzone has not been tested on this compiler. Please contact warzone-dev@gna.org"
|
|
||||||
#endif /* WZ_CC_x */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The window system, must be one of: (WZ_WS_x)
|
|
||||||
|
|
||||||
MACX - Mac OS X
|
|
||||||
WIN32 - Windows
|
|
||||||
X11 - X Window System
|
|
||||||
QNX - QNX
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_WIN32_X11_)
|
|
||||||
# define WZ_WS_X11
|
|
||||||
|
|
||||||
#elif defined(WZ_OS_WIN32)
|
|
||||||
# define WZ_WS_WIN32
|
|
||||||
# if defined(WZ_OS_WIN64)
|
|
||||||
# define WZ_WS_WIN64
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(WZ_OS_MAC)
|
|
||||||
# define WZ_WS_MAC
|
|
||||||
# define WZ_WS_MACX
|
|
||||||
# if defined(WZ_OS_MAC64)
|
|
||||||
# define WZ_WS_MAC64
|
|
||||||
# elif defined(WZ_OS_MAC32)
|
|
||||||
# define WZ_WS_MAC32
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(WZ_OS_QNX)
|
|
||||||
# define WZ_WS_QNX
|
|
||||||
|
|
||||||
#elif defined(WZ_OS_UNIX)
|
|
||||||
# define WZ_WS_X11
|
|
||||||
|
|
||||||
#else
|
|
||||||
# error "Warzone has not been tested on this window system. Please contact warzone-dev@gna.org"
|
|
||||||
#endif /* WZ_WS_x */
|
|
||||||
|
|
||||||
#if defined(WZ_WS_WIN16) || defined(WZ_WS_WIN32)
|
|
||||||
# define WZ_WS_WIN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The supported C standard, must be one of: (WZ_Cxx)
|
|
||||||
|
|
||||||
99 - ISO/IEC 9899:1999 / C99
|
|
||||||
*/
|
|
||||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
|
||||||
# define WZ_C99
|
|
||||||
#endif /* WZ_Cxx */
|
|
||||||
|
|
||||||
/*
|
|
||||||
The supported C++ standard, must be one of: (WZ_CXXxx)
|
|
||||||
|
|
||||||
98 - ISO/IEC 14882:1998 / C++98
|
|
||||||
*/
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
# define WZ_CXX98
|
|
||||||
#endif /* WZ_CXXxx */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Convenience macros to test the versions of gcc.
|
|
||||||
Copied from glibc's features.h.
|
|
||||||
*/
|
|
||||||
#if defined(WZ_CC_GNU) && defined __GNUC__ && defined __GNUC_MINOR__
|
|
||||||
# define WZ_CC_GNU_PREREQ(maj, min) \
|
|
||||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
|
||||||
#else
|
|
||||||
# define WZ_CC_GNU_PREREQ(maj, min) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Convenience macros to test the versions of icc.
|
|
||||||
*/
|
|
||||||
#if defined(WZ_CC_INTEL) && defined __ICC
|
|
||||||
# define WZ_CC_INTEL_PREREQ(maj, min) \
|
|
||||||
((__ICC) >= ((maj) * 100) + (min))
|
|
||||||
#else
|
|
||||||
# define WZ_CC_INTEL_PREREQ(maj, min) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ---- Declaration attributes ---- */
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_DEPRECATED
|
|
||||||
*
|
|
||||||
* The WZ_DECL_DEPRECATED macro can be used to trigger compile-time warnings
|
|
||||||
* with newer compilers when deprecated functions are used.
|
|
||||||
*
|
|
||||||
* For non-inline functions, the macro gets inserted at front of the
|
|
||||||
* function declaration, right before the return type:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* WZ_DECL_DEPRECATED void deprecatedFunctionA();
|
|
||||||
* WZ_DECL_DEPRECATED int deprecatedFunctionB() const;
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* For functions which are implemented inline,
|
|
||||||
* the WZ_DECL_DEPRECATED macro is inserted at the front, right before the return
|
|
||||||
* type, but after "static", "inline" or "virtual":
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* WZ_DECL_DEPRECATED void deprecatedInlineFunctionA() { .. }
|
|
||||||
* virtual WZ_DECL_DEPRECATED int deprecatedInlineFunctionB() { .. }
|
|
||||||
* static WZ_DECL_DEPRECATED bool deprecatedInlineFunctionC() { .. }
|
|
||||||
* inline WZ_DECL_DEPRECATED bool deprecatedInlineFunctionD() { .. }
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* You can also mark whole structs or classes as deprecated, by inserting the
|
|
||||||
* WZ_DECL_DEPRECATED macro after the struct/class keyword, but before the
|
|
||||||
* name of the struct/class:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* class WZ_DECL_DEPRECATED DeprecatedClass { };
|
|
||||||
* struct WZ_DECL_DEPRECATED DeprecatedStruct { };
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* \note
|
|
||||||
* Description copied from KDE4, code copied from Qt4.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(3,2) || WZ_CC_INTEL_PREREQ(10,0)
|
|
||||||
# define WZ_DECL_DEPRECATED __attribute__((__deprecated__))
|
|
||||||
#elif defined(WZ_CC_MSVC) && defined(WZ_CC_MSVC_NET)
|
|
||||||
# define WZ_DECL_DEPRECATED __declspec(deprecated)
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*! \def WZ_DECL_FORMAT
|
|
||||||
* GCC: "The format attribute specifies that a function takes printf, scanf, strftime or strfmon
|
|
||||||
* style arguments which should be type-checked against a format string."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(2,5) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_FORMAT(archetype, string_index, first_to_check) \
|
|
||||||
__attribute__((__format__(archetype, string_index, first_to_check)))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_FORMAT(archetype, string_index, first_to_check)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_NORETURN
|
|
||||||
* "A few standard library functions, such as abort and exit, cannot return. GCC knows this
|
|
||||||
* automatically. Some programs define their own functions that never return.
|
|
||||||
* You can declare them noreturn to tell the compiler this fact."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(2,5) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_NORETURN __attribute__((__noreturn__))
|
|
||||||
#elif defined(WZ_CC_MSVC)
|
|
||||||
# define WZ_DECL_NORETURN __declspec(noreturn)
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_NORETURN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_CONST
|
|
||||||
* GCC: "Many functions do not examine any values except their arguments, and have no effects
|
|
||||||
* except the return value. Basically this is just slightly more strict class than
|
|
||||||
* the pure attribute below, since function is not allowed to read global memory."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(2,5) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_CONST __attribute__((__const__,__warn_unused_result__))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_CONST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_PURE
|
|
||||||
* GCC: "Many functions have no effects except the return value and their return value depends
|
|
||||||
* only on the parameters and/or global variables. Such a function can be subject to
|
|
||||||
* common subexpression elimination and loop optimization just as an arithmetic operator
|
|
||||||
* would be."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(2,96) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_PURE __attribute__((__pure__))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_PURE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_UNUSED
|
|
||||||
* GCC: "This attribute, attached to a function, means that the function is meant to be possibly
|
|
||||||
* unused. GCC will not produce a warning for this function."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(3,2) || WZ_CC_INTEL_PREREQ(10,0)
|
|
||||||
# define WZ_DECL_UNUSED __attribute__((__unused__))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_UNUSED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_WARN_UNUSED_RESULT
|
|
||||||
* GCC: "The warn_unused_result attribute causes a warning to be emitted if a caller of the
|
|
||||||
* function with this attribute does not use its return value. This is useful for
|
|
||||||
* functions where not checking the result is either a security problem or always a bug,
|
|
||||||
* such as realloc."
|
|
||||||
*/
|
|
||||||
#if defined(WZ_CC_GNU) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_WARN_UNUSED_RESULT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*! \def WZ_DECL_MAY_ALIAS
|
|
||||||
* GCC: "Accesses to objects with types with this attribute are not subjected to type-based alias
|
|
||||||
* analysis, but are instead assumed to be able to alias any other type of objects,
|
|
||||||
* just like the char type. See -fstrict-aliasing for more information on aliasing issues."
|
|
||||||
*/
|
|
||||||
#if WZ_CC_GNU_PREREQ(3,3) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_MAY_ALIAS __attribute__((__may_alias__))
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_MAY_ALIAS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \def WZ_DECL_RESTRICT
|
|
||||||
* Apply the "restrict" keyword found in the C99 revision of the standard.
|
|
||||||
* The compiler may assume that the memory referenced by a "restrict" pointer is not aliased
|
|
||||||
* by any other pointer. Thus this forms the opposite of WZ_DECL_MAY_ALIAS.
|
|
||||||
*/
|
|
||||||
#if defined(WZ_C99) && WZ_CC_GNU_PREREQ(4,1) && !defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_RESTRICT restrict
|
|
||||||
#elif defined(WZ_CC_MSVC) && defined(WZ_CC_MSVC_NET)
|
|
||||||
# define WZ_DECL_RESTRICT __restrict
|
|
||||||
#else
|
|
||||||
# define WZ_DECL_RESTRICT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*! \def WZ_DECL_THREAD
|
|
||||||
* Declares a variable to be local to the running thread, and not shared between threads.
|
|
||||||
*/
|
|
||||||
#if defined(WZ_CC_GNU) || defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_DECL_THREAD __thread
|
|
||||||
#elif defined(WZ_CC_MSVC)
|
|
||||||
# define WZ_DECL_THREAD __declspec(thread)
|
|
||||||
#else
|
|
||||||
# error "Thread local storage attribute required"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*! \def WZ_ASSERT_STATIC_STRING
|
|
||||||
* Asserts that the given string is statically allocated.
|
|
||||||
*/
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
# include <typeinfo>
|
|
||||||
# define WZ_ASSERT_STATIC_STRING(_var) assert(typeid(_var) == typeid(char[sizeof(_var)]))
|
|
||||||
#elif defined(WZ_CC_GNU) || defined(WZ_CC_INTEL)
|
|
||||||
# define WZ_ASSERT_STATIC_STRING(_var) STATIC_ASSERT(__builtin_types_compatible_p(typeof(_var), char[]))
|
|
||||||
#else
|
|
||||||
# define WZ_ASSERT_STATIC_STRING(_var) (void)(_var)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*! \def WZ_ASSERT_ARRAY
|
|
||||||
* Asserts that the given variable is a (statically sized) array, not just a pointer.
|
|
||||||
*/
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
# define WZ_ASSERT_ARRAY_EXPR(a) 0
|
|
||||||
#elif defined(WZ_CC_GNU) || defined(WZ_CC_INTEL)
|
|
||||||
/* &a[0] degrades to a pointer: a different type from an array */
|
|
||||||
# define WZ_ASSERT_ARRAY_EXPR(a) STATIC_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(a), typeof(&(a)[0])))
|
|
||||||
#else
|
|
||||||
# define WZ_ASSERT_ARRAY_EXPR(a) 0
|
|
||||||
#endif
|
|
||||||
#define WZ_ASSERT_ARRAY(a) (void)WZ_ASSERT_ARRAY_EXPR(a)
|
|
||||||
|
|
||||||
|
|
||||||
/* ---- Platform specific setup ---- */
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(WZ_OS_WIN)
|
|
||||||
# if defined(WZ_CC_MINGW)
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <sys/param.h>
|
|
||||||
# include <w32api.h>
|
|
||||||
# define _WIN32_IE IE5
|
|
||||||
// Required for alloca
|
|
||||||
# include <malloc.h>
|
|
||||||
|
|
||||||
# elif defined(WZ_CC_MSVC)
|
|
||||||
# if defined(_DEBUG)
|
|
||||||
# define DEBUG
|
|
||||||
# define _CRTDBG_MAP_ALLOC
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <crtdbg.h>
|
|
||||||
# endif /* _DEBUG */
|
|
||||||
# endif /* WZ_CC_* */
|
|
||||||
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# define WIN32_EXTRA_LEAN
|
|
||||||
# undef NOMINMAX
|
|
||||||
# define NOMINMAX 1 // disable the min / max macros
|
|
||||||
# include <windows.h>
|
|
||||||
|
|
||||||
# if defined(WZ_CC_MSVC)
|
|
||||||
// notify people we are disabling these warning messages.
|
|
||||||
# pragma message (" *** Warnings 4018,4100,4127,4204,4244,4267,4389 have been squelched. ***")
|
|
||||||
# pragma warning (disable : 4018) // Shut up: '>' : signed/unsigned mismatch
|
|
||||||
# pragma warning (disable : 4100) // Shut up: unreferenced formal parameter (FIXME)
|
|
||||||
# pragma warning (disable : 4127) // Shut up: conditional expression is constant (eg. "while(0)")
|
|
||||||
# pragma warning (disable : 4204) // Shut up: non-constant aggregate initializer
|
|
||||||
# pragma warning (disable : 4244) // Shut up: conversion from 'float' to 'int', possible loss of data
|
|
||||||
# pragma warning (disable : 4267) // Shut up: conversion from 'size_t' to 'type', possible loss of data
|
|
||||||
# pragma warning (disable : 4389) // Shut up: '==' : signed/unsigned mismatch
|
|
||||||
|
|
||||||
# define strcasecmp _stricmp
|
|
||||||
# define strncasecmp _strnicmp
|
|
||||||
# define inline __inline
|
|
||||||
# define alloca _alloca
|
|
||||||
# define fileno _fileno
|
|
||||||
|
|
||||||
# define isnan _isnan
|
|
||||||
# define isfinite _finite
|
|
||||||
|
|
||||||
# define PATH_MAX MAX_PATH
|
|
||||||
# endif /* WZ_CC_MSVC */
|
|
||||||
|
|
||||||
/* Make sure that PATH_MAX is large enough to use as the size for return
|
|
||||||
* buffers for Windows API calls
|
|
||||||
*/
|
|
||||||
# if (PATH_MAX < MAX_PATH)
|
|
||||||
# undef PATH_MAX
|
|
||||||
# define PATH_MAX MAX_PATH
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(WZ_OS_UNIX)
|
|
||||||
# include <unistd.h>
|
|
||||||
# if defined(HAVE_ALLOCA_H)
|
|
||||||
# include <alloca.h>
|
|
||||||
# endif
|
|
||||||
#endif /* WZ_OS_* */
|
|
||||||
|
|
||||||
// Define PATH_MAX for systems that don't have it, like Hurd
|
|
||||||
#ifndef PATH_MAX
|
|
||||||
#define PATH_MAX 4096
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(WZ_C99) && !defined(va_copy)
|
|
||||||
/**
|
|
||||||
* Implements the interface of the C99 macro va_copy such that we can use it on
|
|
||||||
* non-C99 systems as well.
|
|
||||||
*
|
|
||||||
* This implementation assumes that va_list is just a pointer to the stack
|
|
||||||
* frame of the variadic function. This is by far the most common setup, though
|
|
||||||
* it might not always work.
|
|
||||||
*/
|
|
||||||
# define va_copy(dest, src) (void)((dest) = (src))
|
|
||||||
#endif // !WZ_C99 && !va_copy
|
|
||||||
|
|
||||||
#endif /* WZGLOBAL_H */
|
|
|
@ -1 +0,0 @@
|
||||||
Source code in this directory was taken from Warzone2100 source. Please read COPING.README for licence or visit https://github.com/cybersphinx/wzgraphicsmods for more information.
|
|
|
@ -1,24 +0,0 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
|
||||||
|
|
||||||
char *widgetGetClipboardText()
|
|
||||||
{
|
|
||||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
|
||||||
NSString *myString = [pasteboard stringForType:NSPasteboardTypeString];
|
|
||||||
|
|
||||||
if (myString == nil || [myString length] == 0) return NULL;
|
|
||||||
|
|
||||||
return strdup([myString UTF8String]);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool widgetSetClipboardText(const char *text)
|
|
||||||
{
|
|
||||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
|
||||||
[pasteboard clearContents];
|
|
||||||
|
|
||||||
NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:text];
|
|
||||||
return [pasteboard setString:stringFromUTFString forType:NSStringPboardType];
|
|
||||||
}
|
|
|
@ -1,160 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 2008 Freddie Witherden
|
|
||||||
Copyright (C) 2008-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "utf.h"
|
|
||||||
// Defines most macros and types from <stdbool.h> and <stdint.h>
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
char *widgetGetClipboardText()
|
|
||||||
{
|
|
||||||
uint16_t *clipboardText;
|
|
||||||
char *ourText = NULL;
|
|
||||||
|
|
||||||
// If there is any text on the clipboard, open it
|
|
||||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
|
|
||||||
{
|
|
||||||
// Get any text on the clipboard
|
|
||||||
HANDLE hClipboardData = GetClipboardData(CF_UNICODETEXT);
|
|
||||||
|
|
||||||
// If the handle is valid, fetch the text
|
|
||||||
if (hClipboardData)
|
|
||||||
{
|
|
||||||
// Get the text
|
|
||||||
clipboardText = GlobalLock(hClipboardData);
|
|
||||||
|
|
||||||
// So long as we got something
|
|
||||||
if (clipboardText)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
// Convert it to UTF-8 (from UTF-16)
|
|
||||||
ourText = UTF16toUTF8(clipboardText, NULL);
|
|
||||||
|
|
||||||
// Unlock the text
|
|
||||||
GlobalUnlock(hClipboardData);
|
|
||||||
|
|
||||||
// Strip any '\r' from the text
|
|
||||||
for (i = j = 0; ourText[i]; i++)
|
|
||||||
{
|
|
||||||
if (ourText[i] != '\r')
|
|
||||||
{
|
|
||||||
ourText[j++] = ourText[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NUL terminate
|
|
||||||
ourText[j] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the clipboard
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ourText;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool widgetSetClipboardText(const char *text)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
// Copy of text with \n => \r\n
|
|
||||||
char *newText;
|
|
||||||
|
|
||||||
// UTF-16 version of newText
|
|
||||||
uint16_t *utf16NewText;
|
|
||||||
|
|
||||||
// Number of bytes utf16NewText is in size
|
|
||||||
size_t nbytes;
|
|
||||||
|
|
||||||
int count, i, j;
|
|
||||||
|
|
||||||
// Get the number of '\n' characters in the text
|
|
||||||
for (i = count = 0; text[i]; i++)
|
|
||||||
{
|
|
||||||
if (text[i] == '\n')
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate enough space for the \r\n string
|
|
||||||
newText = malloc(strlen(text) + count + 1);
|
|
||||||
|
|
||||||
// Copy the string, converting \n to \r\n
|
|
||||||
for (i = j = 0; text[i]; i++, j++)
|
|
||||||
{
|
|
||||||
// If the character is a newline prepend a \r
|
|
||||||
if (text[i] == '\n')
|
|
||||||
{
|
|
||||||
newText[j++] = '\r';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the character (\n or otherwise)
|
|
||||||
newText[j] = text[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// NUL terminate
|
|
||||||
newText[j] = '\0';
|
|
||||||
|
|
||||||
// Convert to UTF-16
|
|
||||||
utf16NewText = UTF8toUTF16(newText, &nbytes);
|
|
||||||
|
|
||||||
// Open the clipboard
|
|
||||||
if (OpenClipboard(NULL))
|
|
||||||
{
|
|
||||||
HGLOBAL hGlobal;
|
|
||||||
uint16_t *clipboardText;
|
|
||||||
|
|
||||||
// Empty it (which also transfers ownership of it to ourself)
|
|
||||||
EmptyClipboard();
|
|
||||||
|
|
||||||
// Allocate global space for the text
|
|
||||||
hGlobal = GlobalAlloc(GMEM_MOVEABLE, nbytes);
|
|
||||||
|
|
||||||
// Lock the newly allocated memory
|
|
||||||
clipboardText = GlobalLock(hGlobal);
|
|
||||||
|
|
||||||
// Copy the text
|
|
||||||
memcpy(clipboardText, utf16NewText, nbytes);
|
|
||||||
|
|
||||||
// Unlock the memory (must come before CloseClipboard())
|
|
||||||
GlobalUnlock(hGlobal);
|
|
||||||
|
|
||||||
// Place the handle on the clipboard
|
|
||||||
if (SetClipboardData(CF_UNICODETEXT, hGlobal))
|
|
||||||
{
|
|
||||||
// We were successful
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the clipboard
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the malloc-ed strings
|
|
||||||
free(newText);
|
|
||||||
free(utf16NewText);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,293 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 2008 Freddie Witherden
|
|
||||||
Copyright (C) 2008-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Something wicked this way comes...
|
|
||||||
* Documentation/reference:
|
|
||||||
* http://svr-www.eng.cam.ac.uk/~er258/code/dist/x_clipboard/paste.cc
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <SDL_syswm.h>
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
static SDL_SysWMinfo info;
|
|
||||||
|
|
||||||
// Atoms
|
|
||||||
static Atom XA_CLIPBOARD;
|
|
||||||
static Atom XA_COMPOUND_TEXT;
|
|
||||||
static Atom XA_UTF8_STRING;
|
|
||||||
static Atom XA_TARGETS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters through SDL_Events searching for clipboard requests from the X
|
|
||||||
* server.
|
|
||||||
*
|
|
||||||
* @param evt The event to filter.
|
|
||||||
*/
|
|
||||||
static int widgetClipboardFilterX11(const SDL_Event *evt)
|
|
||||||
{
|
|
||||||
// We are only interested in window manager events
|
|
||||||
if (evt->type == SDL_SYSWMEVENT)
|
|
||||||
{
|
|
||||||
XEvent xevent = evt->syswm.msg->event.xevent;
|
|
||||||
|
|
||||||
// See if the event is a selection/clipboard request
|
|
||||||
if (xevent.type == SelectionRequest)
|
|
||||||
{
|
|
||||||
// Get the request in question
|
|
||||||
XSelectionRequestEvent *request = &xevent.xselectionrequest;
|
|
||||||
|
|
||||||
// Generate a reply to the selection request
|
|
||||||
XSelectionEvent reply;
|
|
||||||
|
|
||||||
reply.type = SelectionNotify;
|
|
||||||
reply.serial = xevent.xany.send_event;
|
|
||||||
reply.send_event = True;
|
|
||||||
reply.display = info.info.x11.display;
|
|
||||||
reply.requestor = request->requestor;
|
|
||||||
reply.selection = request->selection;
|
|
||||||
reply.property = request->property;
|
|
||||||
reply.target = None;
|
|
||||||
reply.time = request->time;
|
|
||||||
|
|
||||||
// They want to know what we can provide/offer
|
|
||||||
if (request->target == XA_TARGETS)
|
|
||||||
{
|
|
||||||
Atom possibleTargets[] =
|
|
||||||
{
|
|
||||||
XA_STRING,
|
|
||||||
XA_UTF8_STRING,
|
|
||||||
XA_COMPOUND_TEXT
|
|
||||||
};
|
|
||||||
|
|
||||||
XChangeProperty(info.info.x11.display, request->requestor,
|
|
||||||
request->property, XA_ATOM, 32, PropModeReplace,
|
|
||||||
(unsigned char *) possibleTargets, 3);
|
|
||||||
}
|
|
||||||
// They want a string (all we can provide)
|
|
||||||
else if (request->target == XA_STRING
|
|
||||||
|| request->target == XA_UTF8_STRING
|
|
||||||
|| request->target == XA_COMPOUND_TEXT)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
char *xdata = XFetchBytes(info.info.x11.display, &len);
|
|
||||||
|
|
||||||
XChangeProperty(info.info.x11.display, request->requestor,
|
|
||||||
request->property, request->target, 8,
|
|
||||||
PropModeReplace, (unsigned char *) xdata,
|
|
||||||
len);
|
|
||||||
XFree(xdata);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Did not have what they wanted, so no property set
|
|
||||||
reply.property = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dispatch the event
|
|
||||||
XSendEvent(request->display, request->requestor, 0, NoEventMask,
|
|
||||||
(XEvent *) &reply);
|
|
||||||
XSync(info.info.x11.display, False);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void widgetInitialiseClipboardX11()
|
|
||||||
{
|
|
||||||
static bool initialised = false;
|
|
||||||
|
|
||||||
if (!initialised)
|
|
||||||
{
|
|
||||||
// Get the window manager information
|
|
||||||
SDL_GetWMInfo(&info);
|
|
||||||
|
|
||||||
// Ensure we're running under X11
|
|
||||||
assert(info.subsystem == SDL_SYSWM_X11);
|
|
||||||
|
|
||||||
// Register the event filter
|
|
||||||
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
|
||||||
SDL_SetEventFilter(widgetClipboardFilterX11);
|
|
||||||
|
|
||||||
// Lock the connection to the X server
|
|
||||||
info.info.x11.lock_func();
|
|
||||||
|
|
||||||
// Get the clipboard atom (it is not defined by default)
|
|
||||||
XA_CLIPBOARD = XInternAtom(info.info.x11.display, "CLIPBOARD", True);
|
|
||||||
|
|
||||||
// Get the compound text type atom
|
|
||||||
XA_COMPOUND_TEXT = XInternAtom(info.info.x11.display, "COMPOUND_TEXT",
|
|
||||||
True);
|
|
||||||
|
|
||||||
// UTF-8 string atom
|
|
||||||
XA_UTF8_STRING = XInternAtom(info.info.x11.display, "UTF8_STRING",
|
|
||||||
True);
|
|
||||||
|
|
||||||
// TARGETS atom
|
|
||||||
XA_TARGETS = XInternAtom(info.info.x11.display, "TARGETS", True);
|
|
||||||
|
|
||||||
// Unlock the connection
|
|
||||||
info.info.x11.unlock_func();
|
|
||||||
|
|
||||||
// We are initialised
|
|
||||||
initialised = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *widgetGetClipboardText()
|
|
||||||
{
|
|
||||||
char *text = NULL;
|
|
||||||
unsigned char *data = NULL;
|
|
||||||
Atom type;
|
|
||||||
int format, result;
|
|
||||||
unsigned long len, bytesLeft, dummy;
|
|
||||||
Window selectionOwner;
|
|
||||||
|
|
||||||
// Make sure we are initialised
|
|
||||||
widgetInitialiseClipboardX11();
|
|
||||||
|
|
||||||
// Lock the connection
|
|
||||||
info.info.x11.lock_func();
|
|
||||||
|
|
||||||
// Get the owner of the clipboard selection
|
|
||||||
selectionOwner = XGetSelectionOwner(info.info.x11.display, XA_CLIPBOARD);
|
|
||||||
|
|
||||||
// If there is a selection (and therefore owner) fetch it
|
|
||||||
if (selectionOwner != None)
|
|
||||||
{
|
|
||||||
SDL_Event event;
|
|
||||||
bool response = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ask the window whom current owns the clipboard to convert it to an
|
|
||||||
* XA_UTF8_STRING and place it into the XA_CLIPBOARD property of our
|
|
||||||
* window.
|
|
||||||
*/
|
|
||||||
XConvertSelection(info.info.x11.display, XA_CLIPBOARD, XA_UTF8_STRING,
|
|
||||||
XA_CLIPBOARD, info.info.x11.window, CurrentTime);
|
|
||||||
XFlush(info.info.x11.display);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We now need to wait for a response from the window that owns the
|
|
||||||
* clipboard.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Unlock the connection so that the SDL event loop may function
|
|
||||||
info.info.x11.unlock_func();
|
|
||||||
|
|
||||||
while (!response)
|
|
||||||
{
|
|
||||||
// Wait for an event
|
|
||||||
SDL_WaitEvent(&event);
|
|
||||||
|
|
||||||
// If the event is a window manager event
|
|
||||||
if (event.type == SDL_SYSWMEVENT)
|
|
||||||
{
|
|
||||||
XEvent xevent = event.syswm.msg->event.xevent;
|
|
||||||
|
|
||||||
// See if it is a response to our request
|
|
||||||
if (xevent.type == SelectionNotify
|
|
||||||
&& xevent.xselection.requestor == info.info.x11.window)
|
|
||||||
{
|
|
||||||
response = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock the connection once again
|
|
||||||
info.info.x11.lock_func();
|
|
||||||
|
|
||||||
// See how much data is there
|
|
||||||
XGetWindowProperty(info.info.x11.display, info.info.x11.window,
|
|
||||||
XA_CLIPBOARD, 0, 0, False, AnyPropertyType, &type,
|
|
||||||
&format, &len, &bytesLeft, &data);
|
|
||||||
|
|
||||||
// If any 0-length data was returned, free it
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
XFree(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there is any data
|
|
||||||
if (bytesLeft)
|
|
||||||
{
|
|
||||||
// Fetch the data
|
|
||||||
result = XGetWindowProperty(info.info.x11.display,
|
|
||||||
info.info.x11.window, XA_CLIPBOARD, 0,
|
|
||||||
bytesLeft, False, AnyPropertyType,
|
|
||||||
&type, &format, &len, &dummy, &data);
|
|
||||||
|
|
||||||
// If we got some data, duplicate it
|
|
||||||
if (result == Success)
|
|
||||||
{
|
|
||||||
text = strdup((char *) data);
|
|
||||||
XFree(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the property now that we are finished with it
|
|
||||||
XDeleteProperty(info.info.x11.display, info.info.x11.window,
|
|
||||||
XA_CLIPBOARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unlock the connection
|
|
||||||
info.info.x11.unlock_func();
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool widgetSetClipboardText(const char *text)
|
|
||||||
{
|
|
||||||
Window selectionOwner;
|
|
||||||
|
|
||||||
// Make sure we are initialised
|
|
||||||
widgetInitialiseClipboardX11();
|
|
||||||
|
|
||||||
// Lock the connection
|
|
||||||
info.info.x11.lock_func();
|
|
||||||
|
|
||||||
// Copy the text into the root windows cut buffer (for Xterm compatibility)
|
|
||||||
XStoreBytes(info.info.x11.display, text, strlen(text) + 1);
|
|
||||||
|
|
||||||
// Set ourself as the owner of the CLIPBOARD atom
|
|
||||||
XSetSelectionOwner(info.info.x11.display, XA_CLIPBOARD,
|
|
||||||
info.info.x11.window, CurrentTime);
|
|
||||||
|
|
||||||
// Check if we acquired ownership or not
|
|
||||||
selectionOwner = XGetSelectionOwner(info.info.x11.display, XA_CLIPBOARD);
|
|
||||||
|
|
||||||
// We got ownership
|
|
||||||
if (selectionOwner == info.info.x11.window)
|
|
||||||
{
|
|
||||||
info.info.x11.unlock_func();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// We did not get ownership
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info.info.x11.unlock_func();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,530 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Warzone 2100.
|
|
||||||
Copyright (C) 2007 Giel van Schijndel
|
|
||||||
Copyright (C) 2007-2009 Warzone Resurrection Project
|
|
||||||
|
|
||||||
Warzone 2100 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 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
$Revision: 9101 $
|
|
||||||
$Id: utf.c 9101 2010-01-10 13:11:55Z zarelsl $
|
|
||||||
$HeadURL: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk/lib/framework/utf.c $
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* Functions to convert between different Unicode Transformation Formats (UTF for short)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "utf.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#if defined(LIB_COMPILE)
|
|
||||||
# define ASSERT(expr, ...) (assert(expr))
|
|
||||||
# define debug(part, ...) ((void)0)
|
|
||||||
#else
|
|
||||||
# include "debug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Assert that non-starting octets are of the form 10xxxxxx
|
|
||||||
#define ASSERT_NON_START_OCTET(octet) \
|
|
||||||
assert((octet & 0xC0) == 0x80 && "invalid non-start UTF-8 octet")
|
|
||||||
|
|
||||||
// Assert that starting octets are either of the form 0xxxxxxx (ASCII) or 11xxxxxx
|
|
||||||
#define ASSERT_START_OCTECT(octet) \
|
|
||||||
assert((octet & 0x80) == 0x00 || (octet & 0xC0) == 0xC0 || !"invalid starting UTF-8 octet")
|
|
||||||
|
|
||||||
// Assert that hexadect (16bit sequence) 1 of UTF-16 surrogate pair sequences are of the form 110110XXXXXXXXXX
|
|
||||||
#define ASSERT_START_HEXADECT(hexadect) \
|
|
||||||
assert(((hexadect) & 0xD800) == 0xD800 && "invalid first UTF-16 hexadect")
|
|
||||||
|
|
||||||
// Assert that hexadect (16bit sequence) 2 of UTF-16 surrogate pair sequences are of the form 110111XXXXXXXXXX
|
|
||||||
#define ASSERT_FINAL_HEXADECT(hexadect) \
|
|
||||||
assert(((hexadect) & 0xDC00) == 0xDC00 && "invalid first UTF-16 hexadect")
|
|
||||||
|
|
||||||
utf_32_char UTF8DecodeChar(const char *utf8_char, const char **next_char)
|
|
||||||
{
|
|
||||||
utf_32_char decoded = '\0';
|
|
||||||
*next_char = utf8_char;
|
|
||||||
|
|
||||||
ASSERT_START_OCTECT(*utf8_char);
|
|
||||||
|
|
||||||
// first octect: 0xxxxxxx: 7 bit (ASCII)
|
|
||||||
if ((*utf8_char & 0x80) == 0x00)
|
|
||||||
{
|
|
||||||
// 1 byte long encoding
|
|
||||||
decoded = *((*next_char)++);
|
|
||||||
}
|
|
||||||
// first octect: 110xxxxx: 11 bit
|
|
||||||
else if ((*utf8_char & 0xe0) == 0xc0)
|
|
||||||
{
|
|
||||||
// 2 byte long encoding
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[1]);
|
|
||||||
|
|
||||||
decoded = (*((*next_char)++) & 0x1f) << 6;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 0;
|
|
||||||
}
|
|
||||||
// first octect: 1110xxxx: 16 bit
|
|
||||||
else if ((*utf8_char & 0xf0) == 0xe0)
|
|
||||||
{
|
|
||||||
// 3 byte long encoding
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[1]);
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[2]);
|
|
||||||
|
|
||||||
decoded = (*((*next_char)++) & 0x0f) << 12;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 6;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 0;
|
|
||||||
}
|
|
||||||
// first octect: 11110xxx: 21 bit
|
|
||||||
else if ((*utf8_char & 0xf8) == 0xf0)
|
|
||||||
{
|
|
||||||
// 4 byte long encoding
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[1]);
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[2]);
|
|
||||||
ASSERT_NON_START_OCTET(utf8_char[3]);
|
|
||||||
|
|
||||||
decoded = (*((*next_char)++) & 0x07) << 18;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 12;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 6;
|
|
||||||
decoded |= (*((*next_char)++) & 0x3f) << 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// apparently this character uses more than 21 bit
|
|
||||||
// this decoder is not developed to cope with those
|
|
||||||
// characters so error out
|
|
||||||
ASSERT(!"out-of-range UTF-8 character", "this UTF-8 character is too large (> 21bits) for this UTF-8 decoder and too large to be a valid Unicode codepoint");
|
|
||||||
}
|
|
||||||
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t UTF8CharacterCount(const char *utf8_string)
|
|
||||||
{
|
|
||||||
size_t length = 0;
|
|
||||||
|
|
||||||
while (*utf8_string != '\0')
|
|
||||||
{
|
|
||||||
UTF8DecodeChar(utf8_string, &utf8_string);
|
|
||||||
|
|
||||||
++length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t UTF16CharacterCount(const uint16_t *utf16)
|
|
||||||
{
|
|
||||||
size_t length = 0;
|
|
||||||
|
|
||||||
while (*utf16)
|
|
||||||
{
|
|
||||||
UTF16DecodeChar(utf16, &utf16);
|
|
||||||
|
|
||||||
++length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t unicode_utf8_char_length(const utf_32_char unicode_char)
|
|
||||||
{
|
|
||||||
// an ASCII character, which uses 7 bit at most, which is one byte in UTF-8
|
|
||||||
if (unicode_char < 0x00000080)
|
|
||||||
return 1; // stores 7 bits
|
|
||||||
else if (unicode_char < 0x00000800)
|
|
||||||
return 2; // stores 11 bits
|
|
||||||
else if (unicode_char < 0x00010000)
|
|
||||||
return 3; // stores 16 bits
|
|
||||||
/* This encoder can deal with < 0x00200000, but Unicode only ranges
|
|
||||||
* from 0x0 to 0x10FFFF. Thus we don't accept anything else.
|
|
||||||
*/
|
|
||||||
else if (unicode_char < 0x00110000)
|
|
||||||
return 4; // stores 21 bits
|
|
||||||
|
|
||||||
/* Apparently this character lies outside the 0x0 - 0x10FFFF
|
|
||||||
* Unicode range, so don't accept it.
|
|
||||||
*/
|
|
||||||
ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint is too large (%u > 0x10FFFF) to be a valid Unicode codepoint", (unsigned int)unicode_char);
|
|
||||||
|
|
||||||
// Dummy value to prevent warnings about missing return from function
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *UTF8CharacterAtOffset(const char *utf8_string, size_t index)
|
|
||||||
{
|
|
||||||
while (*utf8_string != '\0'
|
|
||||||
&& index != 0)
|
|
||||||
{
|
|
||||||
// Move to the next character
|
|
||||||
UTF8DecodeChar(utf8_string, &utf8_string);
|
|
||||||
|
|
||||||
--index;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*utf8_string == '\0')
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char*)utf8_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Encodes a single Unicode character to a UTF-8 encoded string.
|
|
||||||
*
|
|
||||||
* \param unicode_char A UTF-32 encoded Unicode codepoint that will be encoded
|
|
||||||
* into UTF-8. This should be a valid Unicode codepoint
|
|
||||||
* (i.e. ranging from 0x0 to 0x10FFFF inclusive).
|
|
||||||
* \param out_char Points to the position in a buffer where the UTF-8
|
|
||||||
* encoded character can be stored.
|
|
||||||
*
|
|
||||||
* \return A pointer pointing to the first byte <em>after</em> the encoded
|
|
||||||
* UTF-8 sequence. This can be used as the \c out_char parameter for a
|
|
||||||
* next invocation of encode_utf8_char().
|
|
||||||
*/
|
|
||||||
static char *encode_utf8_char(const utf_32_char unicode_char, char *out_char)
|
|
||||||
{
|
|
||||||
char *next_char = out_char;
|
|
||||||
|
|
||||||
// 7 bits
|
|
||||||
if (unicode_char < 0x00000080)
|
|
||||||
{
|
|
||||||
*(next_char++) = unicode_char;
|
|
||||||
}
|
|
||||||
// 11 bits
|
|
||||||
else if (unicode_char < 0x00000800)
|
|
||||||
{
|
|
||||||
// 0xc0 provides the counting bits: 110
|
|
||||||
// then append the 5 most significant bits
|
|
||||||
*(next_char++) = 0xc0 | (unicode_char >> 6);
|
|
||||||
// Put the next 6 bits in a byte of their own
|
|
||||||
*(next_char++) = 0x80 | (unicode_char & 0x3f);
|
|
||||||
}
|
|
||||||
// 16 bits
|
|
||||||
else if (unicode_char < 0x00010000)
|
|
||||||
{
|
|
||||||
// 0xe0 provides the counting bits: 1110
|
|
||||||
// then append the 4 most significant bits
|
|
||||||
*(next_char++) = 0xe0 | (unicode_char >> 12);
|
|
||||||
// Put the next 12 bits in two bytes of their own
|
|
||||||
*(next_char++) = 0x80 | ((unicode_char >> 6) & 0x3f);
|
|
||||||
*(next_char++) = 0x80 | (unicode_char & 0x3f);
|
|
||||||
}
|
|
||||||
// 21 bits
|
|
||||||
/* This encoder can deal with < 0x00200000, but Unicode only ranges
|
|
||||||
* from 0x0 to 0x10FFFF. Thus we don't accept anything else.
|
|
||||||
*/
|
|
||||||
else if (unicode_char < 0x00110000)
|
|
||||||
{
|
|
||||||
// 0xf0 provides the counting bits: 11110
|
|
||||||
// then append the 3 most significant bits
|
|
||||||
*(next_char++) = 0xf0 | (unicode_char >> 18);
|
|
||||||
// Put the next 18 bits in three bytes of their own
|
|
||||||
*(next_char++) = 0x80 | ((unicode_char >> 12) & 0x3f);
|
|
||||||
*(next_char++) = 0x80 | ((unicode_char >> 6) & 0x3f);
|
|
||||||
*(next_char++) = 0x80 | (unicode_char & 0x3f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Apparently this character lies outside the 0x0 - 0x10FFFF
|
|
||||||
* Unicode range, so don't accept it.
|
|
||||||
*/
|
|
||||||
ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint is too large (%u > 0x10FFFF) to be a valid Unicode codepoint", (unsigned int)unicode_char);
|
|
||||||
}
|
|
||||||
|
|
||||||
return next_char;
|
|
||||||
}
|
|
||||||
|
|
||||||
utf_32_char UTF16DecodeChar(const utf_16_char *utf16_char, const utf_16_char **next_char)
|
|
||||||
{
|
|
||||||
utf_32_char decoded;
|
|
||||||
*next_char = utf16_char;
|
|
||||||
|
|
||||||
// Are we dealing with a surrogate pair
|
|
||||||
if (*utf16_char >= 0xD800
|
|
||||||
&& *utf16_char <= 0xDFFF)
|
|
||||||
{
|
|
||||||
ASSERT_START_HEXADECT(utf16_char[0]);
|
|
||||||
ASSERT_FINAL_HEXADECT(utf16_char[1]);
|
|
||||||
|
|
||||||
decoded = (*((*next_char)++) & 0x3ff) << 10;
|
|
||||||
decoded |= *((*next_char)++) & 0x3ff;
|
|
||||||
|
|
||||||
decoded += 0x10000;
|
|
||||||
}
|
|
||||||
// Not a surrogate pair, so it's a valid Unicode codepoint right away
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded = *((*next_char)++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Encodes a single Unicode character to a UTF-16 encoded string.
|
|
||||||
*
|
|
||||||
* \param unicode_char A UTF-32 encoded Unicode codepoint that will be encoded
|
|
||||||
* into UTF-16. This should be a valid Unicode codepoint
|
|
||||||
* (i.e. ranging from 0x0 to 0x10FFFF inclusive).
|
|
||||||
* \param out_char Points to the position in a buffer where the UTF-16
|
|
||||||
* encoded character can be stored.
|
|
||||||
*
|
|
||||||
* \return A pointer pointing to the first byte <em>after</em> the encoded
|
|
||||||
* UTF-16 sequence. This can be used as the \c out_char parameter for a
|
|
||||||
* next invocation of encode_utf16_char().
|
|
||||||
*/
|
|
||||||
static utf_16_char *encode_utf16_char(const utf_32_char unicode_char, utf_16_char *out_char)
|
|
||||||
{
|
|
||||||
utf_16_char *next_char = out_char;
|
|
||||||
|
|
||||||
// 16 bits
|
|
||||||
if (unicode_char < 0x10000)
|
|
||||||
{
|
|
||||||
*(next_char++) = unicode_char;
|
|
||||||
}
|
|
||||||
else if (unicode_char < 0x110000)
|
|
||||||
{
|
|
||||||
const utf_16_char v = unicode_char - 0x10000;
|
|
||||||
|
|
||||||
*(next_char++) = 0xD800 | (v >> 10);
|
|
||||||
*(next_char++) = 0xDC00 | (v & 0x3ff);
|
|
||||||
|
|
||||||
ASSERT_START_HEXADECT(out_char[0]);
|
|
||||||
ASSERT_FINAL_HEXADECT(out_char[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Apparently this character lies outside the 0x0 - 0x10FFFF
|
|
||||||
* Unicode range, and UTF-16 cannot cope with that, so error
|
|
||||||
* out.
|
|
||||||
*/
|
|
||||||
ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint is too large (%u > 0x10FFFF) to be a valid Unicode codepoint", (unsigned int)unicode_char);
|
|
||||||
}
|
|
||||||
|
|
||||||
return next_char;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t utf16_utf8_buffer_length(const utf_16_char* unicode_string)
|
|
||||||
{
|
|
||||||
const utf_16_char* curChar = unicode_string;
|
|
||||||
|
|
||||||
// Determine length of string (in octets) when encoded in UTF-8
|
|
||||||
size_t length = 0;
|
|
||||||
|
|
||||||
while (*curChar)
|
|
||||||
{
|
|
||||||
length += unicode_utf8_char_length(UTF16DecodeChar(curChar, &curChar));
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *UTF16toUTF8(const utf_16_char *unicode_string, size_t *nbytes)
|
|
||||||
{
|
|
||||||
const utf_16_char* curChar;
|
|
||||||
|
|
||||||
const size_t utf8_length = utf16_utf8_buffer_length(unicode_string);
|
|
||||||
|
|
||||||
// Allocate memory to hold the UTF-8 encoded string (plus a terminating nul char)
|
|
||||||
char* utf8_string = malloc(utf8_length + 1);
|
|
||||||
char* curOutPos = utf8_string;
|
|
||||||
|
|
||||||
if (utf8_string == NULL)
|
|
||||||
{
|
|
||||||
debug(LOG_ERROR, "Out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
curChar = unicode_string;
|
|
||||||
while (*curChar)
|
|
||||||
{
|
|
||||||
curOutPos = encode_utf8_char(UTF16DecodeChar(curChar, &curChar), curOutPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the string with a nul character
|
|
||||||
utf8_string[utf8_length] = '\0';
|
|
||||||
|
|
||||||
// Set the number of bytes allocated
|
|
||||||
if (nbytes)
|
|
||||||
{
|
|
||||||
*nbytes = utf8_length + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return utf8_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t utf8_as_utf16_buf_size(const char* utf8_string)
|
|
||||||
{
|
|
||||||
const char* curChar = utf8_string;
|
|
||||||
|
|
||||||
size_t length = 0;
|
|
||||||
while (*curChar != '\0')
|
|
||||||
{
|
|
||||||
const utf_32_char unicode_char = UTF8DecodeChar(curChar, &curChar);
|
|
||||||
|
|
||||||
if (unicode_char < 0x10000)
|
|
||||||
{
|
|
||||||
length += 1;
|
|
||||||
}
|
|
||||||
else if (unicode_char < 0x110000)
|
|
||||||
{
|
|
||||||
length += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Apparently this character lies outside the 0x0 - 0x10FFFF
|
|
||||||
* Unicode range, and UTF-16 cannot cope with that, so error
|
|
||||||
* out.
|
|
||||||
*/
|
|
||||||
ASSERT(!"out-of-range Unicode codepoint", "This Unicode codepoint too large (%u > 0x10FFFF) for the UTF-16 encoding", (unsigned int)unicode_char);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
utf_16_char *UTF8toUTF16(const char* utf8_string, size_t *nbytes)
|
|
||||||
{
|
|
||||||
const char* curChar = utf8_string;
|
|
||||||
const size_t unicode_length = utf8_as_utf16_buf_size(utf8_string);
|
|
||||||
|
|
||||||
// Allocate memory to hold the UTF-16 encoded string (plus a terminating nul)
|
|
||||||
utf_16_char* unicode_string = malloc(sizeof(utf_16_char) * (unicode_length + 1));
|
|
||||||
utf_16_char* curOutPos = unicode_string;
|
|
||||||
|
|
||||||
if (unicode_string == NULL)
|
|
||||||
{
|
|
||||||
debug(LOG_ERROR, "Out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*curChar != '\0')
|
|
||||||
{
|
|
||||||
curOutPos = encode_utf16_char(UTF8DecodeChar(curChar, &curChar), curOutPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the string with a nul
|
|
||||||
unicode_string[unicode_length] = '\0';
|
|
||||||
|
|
||||||
// Set the number of bytes allocated
|
|
||||||
if (nbytes)
|
|
||||||
{
|
|
||||||
*nbytes = sizeof(utf_16_char) * (unicode_length + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return unicode_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
utf_16_char *UTF16CharacterAtOffset(const utf_16_char *utf16_string, size_t index)
|
|
||||||
{
|
|
||||||
while (*utf16_string != '\0'
|
|
||||||
&& index != 0)
|
|
||||||
{
|
|
||||||
// Move to the next character
|
|
||||||
UTF16DecodeChar(utf16_string, &utf16_string);
|
|
||||||
|
|
||||||
--index;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*utf16_string == '\0')
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (utf_16_char*)utf16_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static size_t utf32_utf8_buffer_length(const utf_32_char* unicode_string)
|
|
||||||
{
|
|
||||||
const utf_32_char* curChar;
|
|
||||||
|
|
||||||
// Determine length of string (in octets) when encoded in UTF-8
|
|
||||||
size_t length = 0;
|
|
||||||
for (curChar = unicode_string; *curChar != '\0'; ++curChar)
|
|
||||||
{
|
|
||||||
length += unicode_utf8_char_length(*curChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *UTF32toUTF8(const utf_32_char *unicode_string, size_t *nbytes)
|
|
||||||
{
|
|
||||||
const utf_32_char* curChar;
|
|
||||||
|
|
||||||
const size_t utf8_length = utf32_utf8_buffer_length(unicode_string);
|
|
||||||
|
|
||||||
// Allocate memory to hold the UTF-8 encoded string (plus a terminating nul char)
|
|
||||||
char* utf8_string = malloc(utf8_length + 1);
|
|
||||||
char* curOutPos = utf8_string;
|
|
||||||
|
|
||||||
if (utf8_string == NULL)
|
|
||||||
{
|
|
||||||
debug(LOG_ERROR, "Out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (curChar = unicode_string; *curChar != 0; ++curChar)
|
|
||||||
{
|
|
||||||
curOutPos = encode_utf8_char(*curChar, curOutPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the string with a nul character
|
|
||||||
utf8_string[utf8_length] = '\0';
|
|
||||||
|
|
||||||
// Set the number of bytes allocated
|
|
||||||
if (nbytes)
|
|
||||||
{
|
|
||||||
*nbytes = utf8_length + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return utf8_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
utf_32_char *UTF8toUTF32(const char *utf8_string, size_t *nbytes)
|
|
||||||
{
|
|
||||||
const char* curChar = utf8_string;
|
|
||||||
const size_t unicode_length = UTF8CharacterCount(utf8_string);
|
|
||||||
|
|
||||||
// Allocate memory to hold the UTF-32 encoded string (plus a terminating nul)
|
|
||||||
utf_32_char* unicode_string = malloc(sizeof(utf_32_char) * (unicode_length + 1));
|
|
||||||
utf_32_char* curOutPos = unicode_string;
|
|
||||||
|
|
||||||
if (unicode_string == NULL)
|
|
||||||
{
|
|
||||||
debug(LOG_ERROR, "Out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*curChar != '\0')
|
|
||||||
{
|
|
||||||
*(curOutPos++) = UTF8DecodeChar(curChar, &curChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the string with a nul
|
|
||||||
unicode_string[unicode_length] = '\0';
|
|
||||||
|
|
||||||
// Set the number of bytes allocated
|
|
||||||
if (nbytes)
|
|
||||||
{
|
|
||||||
*nbytes = sizeof(utf_32_char) * (unicode_length + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return unicode_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t utf32len(const utf_32_char *unicode_string)
|
|
||||||
{
|
|
||||||
size_t ret = 0;
|
|
||||||
while (*unicode_string++)
|
|
||||||
++ret;
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -20,9 +20,6 @@ msgstr ""
|
||||||
msgid "Colobot rules!"
|
msgid "Colobot rules!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "SatCom"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Maximize"
|
msgid "Maximize"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -113,9 +110,6 @@ msgstr ""
|
||||||
msgid " Summary:"
|
msgid " Summary:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid " Drivers:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid " Resolution:"
|
msgid " Resolution:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -189,32 +183,6 @@ msgstr ""
|
||||||
msgid "This is example code that cannot be run directly"
|
msgid "This is example code that cannot be run directly"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "\\b;List of objects\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\b;Robots\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\b;Buildings\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\b;Moveable objects\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\b;Aliens\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\c; (none)\\n;\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "\\b;Error\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid ""
|
|
||||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
|
||||||
"working.\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Open"
|
msgid "Open"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -240,13 +208,13 @@ msgstr ""
|
||||||
msgid "Original game developed by:"
|
msgid "Original game developed by:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "www.epsitec.com"
|
msgid "epsitec.com"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Gold Edition development by:"
|
msgid "Gold Edition development by:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "www.colobot.info"
|
msgid "colobot.info"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Recorder"
|
msgid "Recorder"
|
||||||
|
@ -318,6 +286,9 @@ msgstr ""
|
||||||
msgid "Custom levels\\Levels from mods created by the users"
|
msgid "Custom levels\\Levels from mods created by the users"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "SatCom"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Change player\\Change player"
|
msgid "Change player\\Change player"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -399,7 +370,9 @@ msgstr ""
|
||||||
msgid "Film sequences\\Films before and after the missions"
|
msgid "Film sequences\\Films before and after the missions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
msgid ""
|
||||||
|
"Camera border scrolling\\Scrolling when the mouse touches right or left "
|
||||||
|
"border"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
||||||
|
@ -411,7 +384,7 @@ msgstr ""
|
||||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "System mouse\\Use system mouse cursor"
|
msgid "Pause in background\\Pause the game when the window is unfocused"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Automatic indent\\When program editing"
|
msgid "Automatic indent\\When program editing"
|
||||||
|
@ -453,7 +426,7 @@ msgstr ""
|
||||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Quality dynamic shadows\\Enable shadow transparency and self shadowing"
|
msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
||||||
|
@ -544,6 +517,9 @@ msgstr ""
|
||||||
msgid "Pause\\Pause the game without opening menu"
|
msgid "Pause\\Pause the game without opening menu"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Cheat console\\Show cheat console"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Sound effects:\\Volume of engines, voice, shooting, etc."
|
msgid "Sound effects:\\Volume of engines, voice, shooting, etc."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -565,13 +541,13 @@ msgstr ""
|
||||||
msgid "Normal\\Normal sound volume"
|
msgid "Normal\\Normal sound volume"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Use a joystick\\Joystick or keyboard"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Access to solution\\Shows the solution (detailed instructions for missions)"
|
"Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Invert\\Invert values on this axis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "\\New player name"
|
msgid "\\New player name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1388,9 +1364,6 @@ msgstr ""
|
||||||
msgid "Place occupied"
|
msgid "Place occupied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "No other robot"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "You can not carry a radioactive object"
|
msgid "You can not carry a radioactive object"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1403,9 +1376,6 @@ msgstr ""
|
||||||
msgid "Impossible under water"
|
msgid "Impossible under water"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Not enough energy"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Titanium too far away"
|
msgid "Titanium too far away"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1433,13 +1403,7 @@ msgstr ""
|
||||||
msgid "Can not produce not researched object"
|
msgid "Can not produce not researched object"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Ground inappropriate"
|
msgid "Not enough energy"
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Building too close"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Object too close"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Nothing to recycle"
|
msgid "Nothing to recycle"
|
||||||
|
@ -1451,9 +1415,6 @@ msgstr ""
|
||||||
msgid "Error in instruction move"
|
msgid "Error in instruction move"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Object not found"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Goto: inaccessible destination"
|
msgid "Goto: inaccessible destination"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1502,9 +1463,6 @@ msgstr ""
|
||||||
msgid "Analysis already performed"
|
msgid "Analysis already performed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Not yet enough energy"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "No uranium to transform"
|
msgid "No uranium to transform"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1514,6 +1472,9 @@ msgstr ""
|
||||||
msgid "No titanium"
|
msgid "No titanium"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Object too close"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "No information exchange post within range"
|
msgid "No information exchange post within range"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1554,9 +1515,6 @@ msgstr ""
|
||||||
msgid "Building destroyed"
|
msgid "Building destroyed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Can not create this; there are too many objects"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Unable to control enemy objects"
|
msgid "Unable to control enemy objects"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1633,9 +1591,6 @@ msgstr ""
|
||||||
msgid "Current mission saved"
|
msgid "Current mission saved"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Checkpoint crossed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Alien Queen killed"
|
msgid "Alien Queen killed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
140
po/de.po
140
po/de.po
|
@ -30,9 +30,6 @@ msgstr " Liste der Kapitel:"
|
||||||
msgid " Custom levels:"
|
msgid " Custom levels:"
|
||||||
msgstr " Userlevels:"
|
msgstr " Userlevels:"
|
||||||
|
|
||||||
msgid " Drivers:"
|
|
||||||
msgstr " Driver:"
|
|
||||||
|
|
||||||
msgid " Exercises in the chapter:"
|
msgid " Exercises in the chapter:"
|
||||||
msgstr " Liste der Übungen des Kapitels:"
|
msgstr " Liste der Übungen des Kapitels:"
|
||||||
|
|
||||||
|
@ -319,9 +316,6 @@ msgstr "Gebäude fertiggestellt"
|
||||||
msgid "Building destroyed"
|
msgid "Building destroyed"
|
||||||
msgstr "Gebäude zerstört"
|
msgstr "Gebäude zerstört"
|
||||||
|
|
||||||
msgid "Building too close"
|
|
||||||
msgstr "Gebäude zu nahe"
|
|
||||||
|
|
||||||
msgid "Button %1"
|
msgid "Button %1"
|
||||||
msgstr "Knopf %1"
|
msgstr "Knopf %1"
|
||||||
|
|
||||||
|
@ -337,6 +331,13 @@ msgstr "Kamera weiter weg"
|
||||||
msgid "Camera back\\Moves the camera backward"
|
msgid "Camera back\\Moves the camera backward"
|
||||||
msgstr "Kamera weiter\\Bewegung der Kamera rückwärts"
|
msgstr "Kamera weiter\\Bewegung der Kamera rückwärts"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
"Camera border scrolling\\Scrolling when the mouse touches right or left "
|
||||||
|
"border"
|
||||||
|
msgstr ""
|
||||||
|
"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
|
||||||
|
|
||||||
msgid "Camera closer\\Moves the camera forward"
|
msgid "Camera closer\\Moves the camera forward"
|
||||||
msgstr "Kamera näher\\Bewegung der Kamera vorwärts"
|
msgstr "Kamera näher\\Bewegung der Kamera vorwärts"
|
||||||
|
|
||||||
|
@ -355,9 +356,6 @@ msgstr "Kamera rechts"
|
||||||
msgid "Camera up\\Increase camera angle while visiting message origin"
|
msgid "Camera up\\Increase camera angle while visiting message origin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Can not create this; there are too many objects"
|
|
||||||
msgstr "Kein neues Objekt kann erstellt werden (zu viele vorhanden)"
|
|
||||||
|
|
||||||
msgid "Can not produce not researched object"
|
msgid "Can not produce not researched object"
|
||||||
msgstr "Das erforschte Objekt kann nicht produziert werden"
|
msgstr "Das erforschte Objekt kann nicht produziert werden"
|
||||||
|
|
||||||
|
@ -385,12 +383,12 @@ msgstr "Andere Kamera\\Sichtpunkt einstellen"
|
||||||
msgid "Change player\\Change player"
|
msgid "Change player\\Change player"
|
||||||
msgstr "Anderer Spieler\\Spielername ändern"
|
msgstr "Anderer Spieler\\Spielername ändern"
|
||||||
|
|
||||||
|
msgid "Cheat console\\Show cheat console"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Checkpoint"
|
msgid "Checkpoint"
|
||||||
msgstr "Checkpoint"
|
msgstr "Checkpoint"
|
||||||
|
|
||||||
msgid "Checkpoint crossed"
|
|
||||||
msgstr "Checkpoint erreicht"
|
|
||||||
|
|
||||||
msgid "Climb\\Increases the power of the jet"
|
msgid "Climb\\Increases the power of the jet"
|
||||||
msgstr "Steigen\\Leistung des Triebwerks steigern"
|
msgstr "Steigen\\Leistung des Triebwerks steigern"
|
||||||
|
|
||||||
|
@ -518,6 +516,9 @@ msgstr "Schmutz\\Schmutz auf Robotern und Bauten"
|
||||||
msgid "Dynamic lighting\\Mobile light sources"
|
msgid "Dynamic lighting\\Mobile light sources"
|
||||||
msgstr "Dynamische Beleuchtung\\Dynamische Beleuchtung"
|
msgstr "Dynamische Beleuchtung\\Dynamische Beleuchtung"
|
||||||
|
|
||||||
|
msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -672,9 +673,6 @@ msgstr "Grün"
|
||||||
msgid "Green flag"
|
msgid "Green flag"
|
||||||
msgstr "Grüne Fahne"
|
msgstr "Grüne Fahne"
|
||||||
|
|
||||||
msgid "Ground inappropriate"
|
|
||||||
msgstr "Boden ungeeignet"
|
|
||||||
|
|
||||||
msgid "Ground not flat enough"
|
msgid "Ground not flat enough"
|
||||||
msgstr "Boden nicht eben genug"
|
msgstr "Boden nicht eben genug"
|
||||||
|
|
||||||
|
@ -766,6 +764,9 @@ msgstr "Anweisungen\\Anweisungen für die Mission oder Übung"
|
||||||
msgid "Internal error - tell the developers"
|
msgid "Internal error - tell the developers"
|
||||||
msgstr "Interner Fehler - Benachrichtige die Entwickler"
|
msgstr "Interner Fehler - Benachrichtige die Entwickler"
|
||||||
|
|
||||||
|
msgid "Invert\\Invert values on this axis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Jet temperature"
|
msgid "Jet temperature"
|
||||||
msgstr "Triebwerktemperatur"
|
msgstr "Triebwerktemperatur"
|
||||||
|
|
||||||
|
@ -932,9 +933,6 @@ msgstr "Keine Energie mehr"
|
||||||
msgid "No ore in the subsoil"
|
msgid "No ore in the subsoil"
|
||||||
msgstr "Keine unterirdische Erzlagerstätte"
|
msgstr "Keine unterirdische Erzlagerstätte"
|
||||||
|
|
||||||
msgid "No other robot"
|
|
||||||
msgstr "Kein anderer Roboter"
|
|
||||||
|
|
||||||
msgid "No power cell"
|
msgid "No power cell"
|
||||||
msgstr "Keine Batterie"
|
msgstr "Keine Batterie"
|
||||||
|
|
||||||
|
@ -974,9 +972,6 @@ msgstr "Noch nicht genug Energie"
|
||||||
msgid "Not found anything to destroy"
|
msgid "Not found anything to destroy"
|
||||||
msgstr "Nichts zum Zerstampfen gefunden"
|
msgstr "Nichts zum Zerstampfen gefunden"
|
||||||
|
|
||||||
msgid "Not yet enough energy"
|
|
||||||
msgstr "Noch nicht genug Energie"
|
|
||||||
|
|
||||||
msgid "Nothing to analyze"
|
msgid "Nothing to analyze"
|
||||||
msgstr "Nichts zu analysieren"
|
msgstr "Nichts zu analysieren"
|
||||||
|
|
||||||
|
@ -1016,9 +1011,6 @@ msgstr "OK\\Spieler auswählen"
|
||||||
msgid "OK\\Close program editor and return to game"
|
msgid "OK\\Close program editor and return to game"
|
||||||
msgstr "OK\\Programm kompilieren"
|
msgstr "OK\\Programm kompilieren"
|
||||||
|
|
||||||
msgid "Object not found"
|
|
||||||
msgstr "Das Objekt existiert nicht"
|
|
||||||
|
|
||||||
msgid "Object too close"
|
msgid "Object too close"
|
||||||
msgstr "Gegenstand zu nahe"
|
msgstr "Gegenstand zu nahe"
|
||||||
|
|
||||||
|
@ -1064,6 +1056,9 @@ msgstr "Partikel in den Menüs\\Funken und Sterne in den Menüs"
|
||||||
msgid "Paste (Ctrl+v)"
|
msgid "Paste (Ctrl+v)"
|
||||||
msgstr "Einfügen (Ctrl+v)"
|
msgstr "Einfügen (Ctrl+v)"
|
||||||
|
|
||||||
|
msgid "Pause in background\\Pause the game when the window is unfocused"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Pause/continue"
|
msgid "Pause/continue"
|
||||||
msgstr "Pause/Weitermachen"
|
msgstr "Pause/Weitermachen"
|
||||||
|
|
||||||
|
@ -1188,9 +1183,6 @@ msgstr "Öffentlich\\Gemeinsamer Ordner für alle Spieler"
|
||||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||||
msgstr "Beben bei Explosionen\\Die Kamera bebt bei Explosionen"
|
msgstr "Beben bei Explosionen\\Die Kamera bebt bei Explosionen"
|
||||||
|
|
||||||
msgid "Quality dynamic shadows\\Enable shadow transparency and self shadowing"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Quit\\Quit Colobot: Gold Edition"
|
msgid "Quit\\Quit Colobot: Gold Edition"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1326,10 +1318,6 @@ msgstr "Speichern\\Aktuelle Mission speichern"
|
||||||
msgid "Save\\Saves the current mission"
|
msgid "Save\\Saves the current mission"
|
||||||
msgstr "Speichern\\Speichert die Mission"
|
msgstr "Speichern\\Speichert die Mission"
|
||||||
|
|
||||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
|
||||||
msgstr ""
|
|
||||||
"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
|
|
||||||
|
|
||||||
msgid "Select the astronaut\\Selects the astronaut"
|
msgid "Select the astronaut\\Selects the astronaut"
|
||||||
msgstr "Astronauten auswählen\\Astronauten auswählen"
|
msgstr "Astronauten auswählen\\Astronauten auswählen"
|
||||||
|
|
||||||
|
@ -1478,9 +1466,6 @@ msgstr "Überlebenskit"
|
||||||
msgid "Switch bots <-> buildings"
|
msgid "Switch bots <-> buildings"
|
||||||
msgstr "Anzeige Roboter <-> Bauten"
|
msgstr "Anzeige Roboter <-> Bauten"
|
||||||
|
|
||||||
msgid "System mouse\\Use system mouse cursor"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Take off to finish the mission"
|
msgid "Take off to finish the mission"
|
||||||
msgstr "Abheben nach vollbrachter Mission"
|
msgstr "Abheben nach vollbrachter Mission"
|
||||||
|
|
||||||
|
@ -1505,11 +1490,6 @@ msgstr "Der Ausdruck muss einen boolschen Wert ergeben"
|
||||||
msgid "The function returned no value "
|
msgid "The function returned no value "
|
||||||
msgstr "Die Funktion hat kein Ergebnis zurückgegeben"
|
msgstr "Die Funktion hat kein Ergebnis zurückgegeben"
|
||||||
|
|
||||||
msgid ""
|
|
||||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
|
||||||
"working.\n"
|
|
||||||
msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n"
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -1645,9 +1625,6 @@ msgstr "Markierung für unterirdisches Platinvorkommen"
|
||||||
msgid "Uranium ore"
|
msgid "Uranium ore"
|
||||||
msgstr "Platinerz"
|
msgstr "Platinerz"
|
||||||
|
|
||||||
msgid "Use a joystick\\Joystick or keyboard"
|
|
||||||
msgstr "Joystick\\Joystick oder Tastatur"
|
|
||||||
|
|
||||||
msgid "User levels"
|
msgid "User levels"
|
||||||
msgstr "Userlevels"
|
msgstr "Userlevels"
|
||||||
|
|
||||||
|
@ -1837,48 +1814,40 @@ msgstr "\\Violette Fahne"
|
||||||
msgid "\\Yellow flags"
|
msgid "\\Yellow flags"
|
||||||
msgstr "\\Gelbe Fahne"
|
msgstr "\\Gelbe Fahne"
|
||||||
|
|
||||||
msgid "\\b;Aliens\n"
|
msgid "colobot.info"
|
||||||
msgstr "\\b;Listes der Feinde\n"
|
|
||||||
|
|
||||||
msgid "\\b;Buildings\n"
|
|
||||||
msgstr "\\b;Listes der Gebäude\n"
|
|
||||||
|
|
||||||
msgid "\\b;Error\n"
|
|
||||||
msgstr "\\b;Fehler\n"
|
|
||||||
|
|
||||||
msgid "\\b;List of objects\n"
|
|
||||||
msgstr "\\b;Liste der Objekte\n"
|
|
||||||
|
|
||||||
msgid "\\b;Moveable objects\n"
|
|
||||||
msgstr "\\b;Listes der tragbaren Gegenstände\n"
|
|
||||||
|
|
||||||
msgid "\\b;Robots\n"
|
|
||||||
msgstr "\\b;Liste der Roboter\n"
|
|
||||||
|
|
||||||
msgid "\\c; (none)\\n;\n"
|
|
||||||
msgstr "\\c; (keine)\\n;\n"
|
|
||||||
|
|
||||||
msgid "www.colobot.info"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "www.epsitec.com"
|
#, fuzzy
|
||||||
|
msgid "epsitec.com"
|
||||||
msgstr "www.epsitec.com"
|
msgstr "www.epsitec.com"
|
||||||
|
|
||||||
#~ msgid " "
|
#~ msgid " "
|
||||||
#~ msgstr " "
|
#~ msgstr " "
|
||||||
|
|
||||||
|
#~ msgid " Drivers:"
|
||||||
|
#~ msgstr " Driver:"
|
||||||
|
|
||||||
#~ msgid " Missions on this level:"
|
#~ msgid " Missions on this level:"
|
||||||
#~ msgstr " Missionen des Userlevels:"
|
#~ msgstr " Missionen des Userlevels:"
|
||||||
|
|
||||||
#~ msgid "3D sound\\3D positioning of the sound"
|
#~ msgid "3D sound\\3D positioning of the sound"
|
||||||
#~ msgstr "3D-Geräusche\\Orten der Geräusche im Raum"
|
#~ msgstr "3D-Geräusche\\Orten der Geräusche im Raum"
|
||||||
|
|
||||||
|
#~ msgid "Building too close"
|
||||||
|
#~ msgstr "Gebäude zu nahe"
|
||||||
|
|
||||||
#~ msgid "COLOBOT"
|
#~ msgid "COLOBOT"
|
||||||
#~ msgstr "COLOBOT"
|
#~ msgstr "COLOBOT"
|
||||||
|
|
||||||
|
#~ msgid "Can not create this; there are too many objects"
|
||||||
|
#~ msgstr "Kein neues Objekt kann erstellt werden (zu viele vorhanden)"
|
||||||
|
|
||||||
#~ msgid "Cancel\\Keep current player name"
|
#~ msgid "Cancel\\Keep current player name"
|
||||||
#~ msgstr "Abbrechen\\Behält den bisherigen Spieler bei"
|
#~ msgstr "Abbrechen\\Behält den bisherigen Spieler bei"
|
||||||
|
|
||||||
|
#~ msgid "Checkpoint crossed"
|
||||||
|
#~ msgstr "Checkpoint erreicht"
|
||||||
|
|
||||||
#~ msgid "Compass"
|
#~ msgid "Compass"
|
||||||
#~ msgstr "Kompass"
|
#~ msgstr "Kompass"
|
||||||
|
|
||||||
|
@ -1904,6 +1873,9 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
||||||
#~ msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt"
|
#~ msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt"
|
||||||
|
|
||||||
|
#~ msgid "Ground inappropriate"
|
||||||
|
#~ msgstr "Boden ungeeignet"
|
||||||
|
|
||||||
#~ msgid "Key word help\\More detailed help about key words"
|
#~ msgid "Key word help\\More detailed help about key words"
|
||||||
#~ msgstr "Hilfe über Begriff\\Hilfe über einen Begriff"
|
#~ msgstr "Hilfe über Begriff\\Hilfe über einen Begriff"
|
||||||
|
|
||||||
|
@ -1913,9 +1885,18 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
||||||
#~ msgstr "Schatten unter der Maus\\Ein Schatten erscheint unter der Maus"
|
#~ msgstr "Schatten unter der Maus\\Ein Schatten erscheint unter der Maus"
|
||||||
|
|
||||||
|
#~ msgid "No other robot"
|
||||||
|
#~ msgstr "Kein anderer Roboter"
|
||||||
|
|
||||||
|
#~ msgid "Not yet enough energy"
|
||||||
|
#~ msgstr "Noch nicht genug Energie"
|
||||||
|
|
||||||
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
||||||
#~ msgstr "Anzahl Ziergegenstände\\Anzahl Gegenstände ohne Funktion"
|
#~ msgstr "Anzahl Ziergegenstände\\Anzahl Gegenstände ohne Funktion"
|
||||||
|
|
||||||
|
#~ msgid "Object not found"
|
||||||
|
#~ msgstr "Das Objekt existiert nicht"
|
||||||
|
|
||||||
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
||||||
#~ msgstr "Planeten und Sterne\\Kreisende Planeten und Sterne"
|
#~ msgstr "Planeten und Sterne\\Kreisende Planeten und Sterne"
|
||||||
|
|
||||||
|
@ -1940,8 +1921,37 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Textures\\Quality of textures "
|
#~ msgid "Textures\\Quality of textures "
|
||||||
#~ msgstr "Qualität der Texturen\\Qualität der Anzeige"
|
#~ msgstr "Qualität der Texturen\\Qualität der Anzeige"
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||||
|
#~ "working.\n"
|
||||||
|
#~ msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n"
|
||||||
|
|
||||||
|
#~ msgid "Use a joystick\\Joystick or keyboard"
|
||||||
|
#~ msgstr "Joystick\\Joystick oder Tastatur"
|
||||||
|
|
||||||
#~ msgid "User\\User levels"
|
#~ msgid "User\\User levels"
|
||||||
#~ msgstr "User\\Userlevels"
|
#~ msgstr "User\\Userlevels"
|
||||||
|
|
||||||
#~ msgid "\\Return to COLOBOT"
|
#~ msgid "\\Return to COLOBOT"
|
||||||
#~ msgstr "\\Zurück zu COLOBOT"
|
#~ msgstr "\\Zurück zu COLOBOT"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Aliens\n"
|
||||||
|
#~ msgstr "\\b;Listes der Feinde\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Buildings\n"
|
||||||
|
#~ msgstr "\\b;Listes der Gebäude\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Error\n"
|
||||||
|
#~ msgstr "\\b;Fehler\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;List of objects\n"
|
||||||
|
#~ msgstr "\\b;Liste der Objekte\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Moveable objects\n"
|
||||||
|
#~ msgstr "\\b;Listes der tragbaren Gegenstände\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Robots\n"
|
||||||
|
#~ msgstr "\\b;Liste der Roboter\n"
|
||||||
|
|
||||||
|
#~ msgid "\\c; (none)\\n;\n"
|
||||||
|
#~ msgstr "\\c; (keine)\\n;\n"
|
||||||
|
|
161
po/fr.po
161
po/fr.po
|
@ -1,10 +1,10 @@
|
||||||
# Didier Raboud <odyx@debian.org>, 2012, 2015.
|
# Didier Raboud <odyx@debian.org>, 2012, 2015, 2016.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Colobot 0.1.6\n"
|
"Project-Id-Version: Colobot 0.1.6\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: DATE\n"
|
"POT-Creation-Date: DATE\n"
|
||||||
"PO-Revision-Date: 2015-09-13 12:12+0100\n"
|
"PO-Revision-Date: 2016-03-25 15:01+0100\n"
|
||||||
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
|
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
|
||||||
"Language: fr\n"
|
"Language: fr\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -24,9 +24,6 @@ msgstr " Liste des chapitres :"
|
||||||
msgid " Custom levels:"
|
msgid " Custom levels:"
|
||||||
msgstr " Niveaux spéciaux :"
|
msgstr " Niveaux spéciaux :"
|
||||||
|
|
||||||
msgid " Drivers:"
|
|
||||||
msgstr " Pilotes :"
|
|
||||||
|
|
||||||
msgid " Exercises in the chapter:"
|
msgid " Exercises in the chapter:"
|
||||||
msgstr " Liste des exercices du chapitre :"
|
msgstr " Liste des exercices du chapitre :"
|
||||||
|
|
||||||
|
@ -312,9 +309,6 @@ msgstr "Bâtiment terminé"
|
||||||
msgid "Building destroyed"
|
msgid "Building destroyed"
|
||||||
msgstr "Bâtiment détruit"
|
msgstr "Bâtiment détruit"
|
||||||
|
|
||||||
msgid "Building too close"
|
|
||||||
msgstr "Bâtiment trop proche"
|
|
||||||
|
|
||||||
msgid "Button %1"
|
msgid "Button %1"
|
||||||
msgstr "Bouton %1"
|
msgstr "Bouton %1"
|
||||||
|
|
||||||
|
@ -330,6 +324,13 @@ msgstr "Caméra plus loin"
|
||||||
msgid "Camera back\\Moves the camera backward"
|
msgid "Camera back\\Moves the camera backward"
|
||||||
msgstr "Caméra plus loin\\Recule la caméra"
|
msgstr "Caméra plus loin\\Recule la caméra"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Camera border scrolling\\Scrolling when the mouse touches right or left "
|
||||||
|
"border"
|
||||||
|
msgstr ""
|
||||||
|
"Défilement dans les bords\\Défilement lorsque la souris touche les bords "
|
||||||
|
"gauche ou droite"
|
||||||
|
|
||||||
msgid "Camera closer\\Moves the camera forward"
|
msgid "Camera closer\\Moves the camera forward"
|
||||||
msgstr "Caméra plus proche\\Avance la caméra"
|
msgstr "Caméra plus proche\\Avance la caméra"
|
||||||
|
|
||||||
|
@ -349,11 +350,8 @@ msgstr "Caméra à droite"
|
||||||
|
|
||||||
msgid "Camera up\\Increase camera angle while visiting message origin"
|
msgid "Camera up\\Increase camera angle while visiting message origin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Caméra plus haute\\Augmente l'angle de caméra lors de la vue de l'origine des "
|
"Caméra plus haute\\Augmente l'angle de caméra lors de la vue de l'origine "
|
||||||
"messages"
|
"des messages"
|
||||||
|
|
||||||
msgid "Can not create this; there are too many objects"
|
|
||||||
msgstr "Création impossible; il y a trop d'objets"
|
|
||||||
|
|
||||||
msgid "Can not produce not researched object"
|
msgid "Can not produce not researched object"
|
||||||
msgstr "Impossible de créer un objet n'ayant pas été recherché"
|
msgstr "Impossible de créer un objet n'ayant pas été recherché"
|
||||||
|
@ -382,12 +380,12 @@ msgstr "Changement de caméra\\Autre de point de vue"
|
||||||
msgid "Change player\\Change player"
|
msgid "Change player\\Change player"
|
||||||
msgstr "Autre joueur\\Choix du nom du joueur"
|
msgstr "Autre joueur\\Choix du nom du joueur"
|
||||||
|
|
||||||
|
msgid "Cheat console\\Show cheat console"
|
||||||
|
msgstr "Console de triche\\Montre la console de triche"
|
||||||
|
|
||||||
msgid "Checkpoint"
|
msgid "Checkpoint"
|
||||||
msgstr "Indicateur"
|
msgstr "Indicateur"
|
||||||
|
|
||||||
msgid "Checkpoint crossed"
|
|
||||||
msgstr "Indicateur atteint"
|
|
||||||
|
|
||||||
msgid "Climb\\Increases the power of the jet"
|
msgid "Climb\\Increases the power of the jet"
|
||||||
msgstr "Monter\\Augmenter la puissance du réacteur"
|
msgstr "Monter\\Augmenter la puissance du réacteur"
|
||||||
|
|
||||||
|
@ -513,6 +511,9 @@ msgstr "Salissures\\Salissures des robots et bâtiments"
|
||||||
msgid "Dynamic lighting\\Mobile light sources"
|
msgid "Dynamic lighting\\Mobile light sources"
|
||||||
msgstr "Lumières dynamiques\\Éclairages mobiles"
|
msgstr "Lumières dynamiques\\Éclairages mobiles"
|
||||||
|
|
||||||
|
msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
||||||
|
msgstr "Ombres dynamiques ++\\Active les ombres dynamiques et l'auto-ombrage"
|
||||||
|
|
||||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||||
msgstr "Ombres dynamiques\\Magnifiques ombres !"
|
msgstr "Ombres dynamiques\\Magnifiques ombres !"
|
||||||
|
|
||||||
|
@ -667,9 +668,6 @@ msgstr "Vert"
|
||||||
msgid "Green flag"
|
msgid "Green flag"
|
||||||
msgstr "Drapeau vert"
|
msgstr "Drapeau vert"
|
||||||
|
|
||||||
msgid "Ground inappropriate"
|
|
||||||
msgstr "Terrain inadapté"
|
|
||||||
|
|
||||||
msgid "Ground not flat enough"
|
msgid "Ground not flat enough"
|
||||||
msgstr "Sol pas assez plat"
|
msgstr "Sol pas assez plat"
|
||||||
|
|
||||||
|
@ -760,6 +758,9 @@ msgstr "Instructions mission\\Marche à suivre"
|
||||||
msgid "Internal error - tell the developers"
|
msgid "Internal error - tell the developers"
|
||||||
msgstr "Erreur interne - contacter les développeurs"
|
msgstr "Erreur interne - contacter les développeurs"
|
||||||
|
|
||||||
|
msgid "Invert\\Invert values on this axis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Jet temperature"
|
msgid "Jet temperature"
|
||||||
msgstr "Température du réacteur"
|
msgstr "Température du réacteur"
|
||||||
|
|
||||||
|
@ -924,9 +925,6 @@ msgstr "Plus d'énergie"
|
||||||
msgid "No ore in the subsoil"
|
msgid "No ore in the subsoil"
|
||||||
msgstr "Pas de minerai en sous-sol"
|
msgstr "Pas de minerai en sous-sol"
|
||||||
|
|
||||||
msgid "No other robot"
|
|
||||||
msgstr "Pas d'autre robot"
|
|
||||||
|
|
||||||
msgid "No power cell"
|
msgid "No power cell"
|
||||||
msgstr "Pas de pile"
|
msgstr "Pas de pile"
|
||||||
|
|
||||||
|
@ -966,9 +964,6 @@ msgstr "Pas encore assez d'énergie"
|
||||||
msgid "Not found anything to destroy"
|
msgid "Not found anything to destroy"
|
||||||
msgstr "Rien trouvé à détruire"
|
msgstr "Rien trouvé à détruire"
|
||||||
|
|
||||||
msgid "Not yet enough energy"
|
|
||||||
msgstr "Pas encore assez d'énergie"
|
|
||||||
|
|
||||||
msgid "Nothing to analyze"
|
msgid "Nothing to analyze"
|
||||||
msgstr "Rien à analyser"
|
msgstr "Rien à analyser"
|
||||||
|
|
||||||
|
@ -1008,9 +1003,6 @@ msgstr "D'accord\\Choisir le joueur"
|
||||||
msgid "OK\\Close program editor and return to game"
|
msgid "OK\\Close program editor and return to game"
|
||||||
msgstr "D'accord\\Compiler le programme"
|
msgstr "D'accord\\Compiler le programme"
|
||||||
|
|
||||||
msgid "Object not found"
|
|
||||||
msgstr "Objet n'existe pas"
|
|
||||||
|
|
||||||
msgid "Object too close"
|
msgid "Object too close"
|
||||||
msgstr "Objet trop proche"
|
msgstr "Objet trop proche"
|
||||||
|
|
||||||
|
@ -1056,6 +1048,9 @@ msgstr "Particules dans l'interface\\Pluie de particules"
|
||||||
msgid "Paste (Ctrl+v)"
|
msgid "Paste (Ctrl+v)"
|
||||||
msgstr "Coller (Ctrl+v)"
|
msgstr "Coller (Ctrl+v)"
|
||||||
|
|
||||||
|
msgid "Pause in background\\Pause the game when the window is unfocused"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Pause/continue"
|
msgid "Pause/continue"
|
||||||
msgstr "Pause/continuer"
|
msgstr "Pause/continuer"
|
||||||
|
|
||||||
|
@ -1179,11 +1174,6 @@ msgstr "Public\\Dossier commun à tous les joueurs"
|
||||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||||
msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion"
|
msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion"
|
||||||
|
|
||||||
msgid "Quality dynamic shadows\\Enable shadow transparency and self shadowing"
|
|
||||||
msgstr ""
|
|
||||||
"Ombres projetées\\Active la transparence des ombres et "
|
|
||||||
"l'auto-ombrage"
|
|
||||||
|
|
||||||
msgid "Quit\\Quit Colobot: Gold Edition"
|
msgid "Quit\\Quit Colobot: Gold Edition"
|
||||||
msgstr "Quitter\\Quitter Colobot : Édition Gold"
|
msgstr "Quitter\\Quitter Colobot : Édition Gold"
|
||||||
|
|
||||||
|
@ -1316,11 +1306,6 @@ msgstr "Enregistrer\\Enregistrer la mission en cours"
|
||||||
msgid "Save\\Saves the current mission"
|
msgid "Save\\Saves the current mission"
|
||||||
msgstr "Enregistrer\\Enregistrer la mission en cours"
|
msgstr "Enregistrer\\Enregistrer la mission en cours"
|
||||||
|
|
||||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
|
||||||
msgstr ""
|
|
||||||
"Défilement dans les bords\\Défilement lorsque la souris touches les bords "
|
|
||||||
"gauche ou droite"
|
|
||||||
|
|
||||||
msgid "Select the astronaut\\Selects the astronaut"
|
msgid "Select the astronaut\\Selects the astronaut"
|
||||||
msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute"
|
msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute"
|
||||||
|
|
||||||
|
@ -1329,8 +1314,8 @@ msgstr "Terminateur point-virgule non trouvé"
|
||||||
|
|
||||||
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Résolution des ombres\\Plus grand implique une meilleure qulité et amplitude, "
|
"Résolution des ombres\\Plus grand implique une meilleure qulité et "
|
||||||
"mais plus lent"
|
"amplitude, mais plus lent"
|
||||||
|
|
||||||
msgid "Shield level"
|
msgid "Shield level"
|
||||||
msgstr "Niveau du bouclier"
|
msgstr "Niveau du bouclier"
|
||||||
|
@ -1465,9 +1450,6 @@ msgstr "Sac de survie"
|
||||||
msgid "Switch bots <-> buildings"
|
msgid "Switch bots <-> buildings"
|
||||||
msgstr "Permute robots <-> bâtiments"
|
msgstr "Permute robots <-> bâtiments"
|
||||||
|
|
||||||
msgid "System mouse\\Use system mouse cursor"
|
|
||||||
msgstr "Souris système\\Utiliser le curseur de la souris système"
|
|
||||||
|
|
||||||
msgid "Take off to finish the mission"
|
msgid "Take off to finish the mission"
|
||||||
msgstr "Décolle pour terminer la mission"
|
msgstr "Décolle pour terminer la mission"
|
||||||
|
|
||||||
|
@ -1492,11 +1474,6 @@ msgstr "L'expression doit ętre un boolean"
|
||||||
msgid "The function returned no value "
|
msgid "The function returned no value "
|
||||||
msgstr "La fonction n'a pas retourné de résultat"
|
msgstr "La fonction n'a pas retourné de résultat"
|
||||||
|
|
||||||
msgid ""
|
|
||||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
|
||||||
"working.\n"
|
|
||||||
msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n"
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -1633,9 +1610,6 @@ msgstr "Emplacement pour derrick (uranium)"
|
||||||
msgid "Uranium ore"
|
msgid "Uranium ore"
|
||||||
msgstr "Minerai d'uranium"
|
msgstr "Minerai d'uranium"
|
||||||
|
|
||||||
msgid "Use a joystick\\Joystick or keyboard"
|
|
||||||
msgstr "Utilise un joystick\\Joystick ou clavier"
|
|
||||||
|
|
||||||
msgid "User levels"
|
msgid "User levels"
|
||||||
msgstr "Niveaux supplémentaires"
|
msgstr "Niveaux supplémentaires"
|
||||||
|
|
||||||
|
@ -1826,48 +1800,39 @@ msgstr "\\Drapeaux violets"
|
||||||
msgid "\\Yellow flags"
|
msgid "\\Yellow flags"
|
||||||
msgstr "\\Drapeaux jaunes"
|
msgstr "\\Drapeaux jaunes"
|
||||||
|
|
||||||
msgid "\\b;Aliens\n"
|
msgid "colobot.info"
|
||||||
msgstr "\\b;Listes des ennemis\n"
|
msgstr "colobot.info"
|
||||||
|
|
||||||
msgid "\\b;Buildings\n"
|
msgid "epsitec.com"
|
||||||
msgstr "\\b;Listes des bâtiments\n"
|
msgstr "epsitec.com"
|
||||||
|
|
||||||
msgid "\\b;Error\n"
|
|
||||||
msgstr "\\b;Erreur\n"
|
|
||||||
|
|
||||||
msgid "\\b;List of objects\n"
|
|
||||||
msgstr "\\b;Listes des objets\n"
|
|
||||||
|
|
||||||
msgid "\\b;Moveable objects\n"
|
|
||||||
msgstr "\\b;Listes des objets transportables\n"
|
|
||||||
|
|
||||||
msgid "\\b;Robots\n"
|
|
||||||
msgstr "\\b;Listes des robots\n"
|
|
||||||
|
|
||||||
msgid "\\c; (none)\\n;\n"
|
|
||||||
msgstr "\\c; (aucun)\\n;\n"
|
|
||||||
|
|
||||||
msgid "www.colobot.info"
|
|
||||||
msgstr "www.colobot.info"
|
|
||||||
|
|
||||||
msgid "www.epsitec.com"
|
|
||||||
msgstr "www.epsitec.com"
|
|
||||||
|
|
||||||
#~ msgid " "
|
#~ msgid " "
|
||||||
#~ msgstr " "
|
#~ msgstr " "
|
||||||
|
|
||||||
|
#~ msgid " Drivers:"
|
||||||
|
#~ msgstr " Pilotes :"
|
||||||
|
|
||||||
#~ msgid " Missions on this level:"
|
#~ msgid " Missions on this level:"
|
||||||
#~ msgstr " Missions du niveau :"
|
#~ msgstr " Missions du niveau :"
|
||||||
|
|
||||||
#~ msgid "3D sound\\3D positioning of the sound"
|
#~ msgid "3D sound\\3D positioning of the sound"
|
||||||
#~ msgstr "Bruitages 3D\\Positionnement sonore dans l'espace"
|
#~ msgstr "Bruitages 3D\\Positionnement sonore dans l'espace"
|
||||||
|
|
||||||
|
#~ msgid "Building too close"
|
||||||
|
#~ msgstr "Bâtiment trop proche"
|
||||||
|
|
||||||
#~ msgid "COLOBOT"
|
#~ msgid "COLOBOT"
|
||||||
#~ msgstr "COLOBOT"
|
#~ msgstr "COLOBOT"
|
||||||
|
|
||||||
|
#~ msgid "Can not create this; there are too many objects"
|
||||||
|
#~ msgstr "Création impossible; il y a trop d'objets"
|
||||||
|
|
||||||
#~ msgid "Cancel\\Keep current player name"
|
#~ msgid "Cancel\\Keep current player name"
|
||||||
#~ msgstr "Annuler\\Conserver le joueur actuel"
|
#~ msgstr "Annuler\\Conserver le joueur actuel"
|
||||||
|
|
||||||
|
#~ msgid "Checkpoint crossed"
|
||||||
|
#~ msgstr "Indicateur atteint"
|
||||||
|
|
||||||
#~ msgid "Compass"
|
#~ msgid "Compass"
|
||||||
#~ msgstr "Boussole"
|
#~ msgstr "Boussole"
|
||||||
|
|
||||||
|
@ -1893,6 +1858,9 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
||||||
#~ msgstr "Dégâts à soi-même\\Vos tirs infligent des dommages à vos unités"
|
#~ msgstr "Dégâts à soi-même\\Vos tirs infligent des dommages à vos unités"
|
||||||
|
|
||||||
|
#~ msgid "Ground inappropriate"
|
||||||
|
#~ msgstr "Terrain inadapté"
|
||||||
|
|
||||||
#~ msgid "Key word help\\More detailed help about key words"
|
#~ msgid "Key word help\\More detailed help about key words"
|
||||||
#~ msgstr "Instructions mot-clé\\Explication sur le mot-clé"
|
#~ msgstr "Instructions mot-clé\\Explication sur le mot-clé"
|
||||||
|
|
||||||
|
@ -1902,9 +1870,18 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
||||||
#~ msgstr "Souris ombrée\\Jolie souris avec une ombre"
|
#~ msgstr "Souris ombrée\\Jolie souris avec une ombre"
|
||||||
|
|
||||||
|
#~ msgid "No other robot"
|
||||||
|
#~ msgstr "Pas d'autre robot"
|
||||||
|
|
||||||
|
#~ msgid "Not yet enough energy"
|
||||||
|
#~ msgstr "Pas encore assez d'énergie"
|
||||||
|
|
||||||
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
||||||
#~ msgstr "Nb d'objets décoratifs\\Qualité d'objets non indispensables"
|
#~ msgstr "Nb d'objets décoratifs\\Qualité d'objets non indispensables"
|
||||||
|
|
||||||
|
#~ msgid "Object not found"
|
||||||
|
#~ msgstr "Objet n'existe pas"
|
||||||
|
|
||||||
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
||||||
#~ msgstr "Planètes et étoiles\\Motifs mobiles dans le ciel"
|
#~ msgstr "Planètes et étoiles\\Motifs mobiles dans le ciel"
|
||||||
|
|
||||||
|
@ -1926,11 +1903,43 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Sunbeams\\Sunbeams in the sky"
|
#~ msgid "Sunbeams\\Sunbeams in the sky"
|
||||||
#~ msgstr "Rayons du soleil\\Rayons selon l'orientation"
|
#~ msgstr "Rayons du soleil\\Rayons selon l'orientation"
|
||||||
|
|
||||||
|
#~ msgid "System mouse\\Use system mouse cursor"
|
||||||
|
#~ msgstr "Souris système\\Utiliser le curseur de la souris système"
|
||||||
|
|
||||||
#~ msgid "Textures\\Quality of textures "
|
#~ msgid "Textures\\Quality of textures "
|
||||||
#~ msgstr "Qualité des textures\\Qualité des images"
|
#~ msgstr "Qualité des textures\\Qualité des images"
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||||
|
#~ "working.\n"
|
||||||
|
#~ msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n"
|
||||||
|
|
||||||
|
#~ msgid "Use a joystick\\Joystick or keyboard"
|
||||||
|
#~ msgstr "Utilise un joystick\\Joystick ou clavier"
|
||||||
|
|
||||||
#~ msgid "User\\User levels"
|
#~ msgid "User\\User levels"
|
||||||
#~ msgstr "Suppl.\\Niveaux supplémentaires"
|
#~ msgstr "Suppl.\\Niveaux supplémentaires"
|
||||||
|
|
||||||
#~ msgid "\\Return to COLOBOT"
|
#~ msgid "\\Return to COLOBOT"
|
||||||
#~ msgstr "\\Retourner dans COLOBOT"
|
#~ msgstr "\\Retourner dans COLOBOT"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Aliens\n"
|
||||||
|
#~ msgstr "\\b;Listes des ennemis\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Buildings\n"
|
||||||
|
#~ msgstr "\\b;Listes des bâtiments\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Error\n"
|
||||||
|
#~ msgstr "\\b;Erreur\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;List of objects\n"
|
||||||
|
#~ msgstr "\\b;Listes des objets\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Moveable objects\n"
|
||||||
|
#~ msgstr "\\b;Listes des objets transportables\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Robots\n"
|
||||||
|
#~ msgstr "\\b;Listes des robots\n"
|
||||||
|
|
||||||
|
#~ msgid "\\c; (none)\\n;\n"
|
||||||
|
#~ msgstr "\\c; (aucun)\\n;\n"
|
||||||
|
|
168
po/pl.po
168
po/pl.po
|
@ -30,9 +30,6 @@ msgstr " Rozdziały:"
|
||||||
msgid " Custom levels:"
|
msgid " Custom levels:"
|
||||||
msgstr " Własne poziomy:"
|
msgstr " Własne poziomy:"
|
||||||
|
|
||||||
msgid " Drivers:"
|
|
||||||
msgstr " Sterowniki:"
|
|
||||||
|
|
||||||
msgid " Exercises in the chapter:"
|
msgid " Exercises in the chapter:"
|
||||||
msgstr " Ćwiczenia w tym rozdziale:"
|
msgstr " Ćwiczenia w tym rozdziale:"
|
||||||
|
|
||||||
|
@ -134,7 +131,7 @@ msgid "Analyzes only organic matter"
|
||||||
msgstr "Analizuje jedynie materię organiczną"
|
msgstr "Analizuje jedynie materię organiczną"
|
||||||
|
|
||||||
msgid "Anisotropy level\\Anisotropy level"
|
msgid "Anisotropy level\\Anisotropy level"
|
||||||
msgstr ""
|
msgstr "Filtrowanie anizotropowe\\Poziom filtrowania anizotropowego"
|
||||||
|
|
||||||
msgid "Ant"
|
msgid "Ant"
|
||||||
msgstr "Mrówka"
|
msgstr "Mrówka"
|
||||||
|
@ -322,9 +319,6 @@ msgstr "Budowa zakończona"
|
||||||
msgid "Building destroyed"
|
msgid "Building destroyed"
|
||||||
msgstr "Budynek zniszczony"
|
msgstr "Budynek zniszczony"
|
||||||
|
|
||||||
msgid "Building too close"
|
|
||||||
msgstr "Budynek za blisko"
|
|
||||||
|
|
||||||
msgid "Button %1"
|
msgid "Button %1"
|
||||||
msgstr "Przycisk %1"
|
msgstr "Przycisk %1"
|
||||||
|
|
||||||
|
@ -340,6 +334,13 @@ msgstr "Camera awayest"
|
||||||
msgid "Camera back\\Moves the camera backward"
|
msgid "Camera back\\Moves the camera backward"
|
||||||
msgstr "Kamera dalej\\Oddala kamerę"
|
msgstr "Kamera dalej\\Oddala kamerę"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Camera border scrolling\\Scrolling when the mouse touches right or left "
|
||||||
|
"border"
|
||||||
|
msgstr ""
|
||||||
|
"Przewijanie kamery przy krawędzi\\Ekran jest przewijany gdy mysz dotknie "
|
||||||
|
"prawej lub lewej jego krawędzi"
|
||||||
|
|
||||||
msgid "Camera closer\\Moves the camera forward"
|
msgid "Camera closer\\Moves the camera forward"
|
||||||
msgstr "Kamera bliżej\\Przybliża kamerę"
|
msgstr "Kamera bliżej\\Przybliża kamerę"
|
||||||
|
|
||||||
|
@ -358,9 +359,6 @@ msgstr "Camera to right"
|
||||||
msgid "Camera up\\Increase camera angle while visiting message origin"
|
msgid "Camera up\\Increase camera angle while visiting message origin"
|
||||||
msgstr "Kamera w górę\\Podnieś kamerę podczas sprawdzania źródła wiadomości"
|
msgstr "Kamera w górę\\Podnieś kamerę podczas sprawdzania źródła wiadomości"
|
||||||
|
|
||||||
msgid "Can not create this; there are too many objects"
|
|
||||||
msgstr "Nie można tego utworzyć, za dużo obiektów"
|
|
||||||
|
|
||||||
msgid "Can not produce not researched object"
|
msgid "Can not produce not researched object"
|
||||||
msgstr "Nie można wyprodukować nie wynalezionego obiektu"
|
msgstr "Nie można wyprodukować nie wynalezionego obiektu"
|
||||||
|
|
||||||
|
@ -388,12 +386,12 @@ msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą"
|
||||||
msgid "Change player\\Change player"
|
msgid "Change player\\Change player"
|
||||||
msgstr "Zmień gracza\\Zmień gracza"
|
msgstr "Zmień gracza\\Zmień gracza"
|
||||||
|
|
||||||
|
msgid "Cheat console\\Show cheat console"
|
||||||
|
msgstr "Konsola komend\\Pokaż konsolę komend"
|
||||||
|
|
||||||
msgid "Checkpoint"
|
msgid "Checkpoint"
|
||||||
msgstr "Punkt kontrolny"
|
msgstr "Punkt kontrolny"
|
||||||
|
|
||||||
msgid "Checkpoint crossed"
|
|
||||||
msgstr "Przekroczono punkt kontrolny"
|
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
|
@ -413,7 +411,8 @@ msgid "Code battles"
|
||||||
msgstr "Programobitwy"
|
msgstr "Programobitwy"
|
||||||
|
|
||||||
msgid "Code battles\\Program your robot to be the best of them all!"
|
msgid "Code battles\\Program your robot to be the best of them all!"
|
||||||
msgstr "Programobitwy\\Zaprogramuj swego robota by był najlepszy ze wszystkich!"
|
msgstr ""
|
||||||
|
"Programobitwy\\Zaprogramuj swego robota by był najlepszy ze wszystkich!"
|
||||||
|
|
||||||
msgid "Colobot rules!"
|
msgid "Colobot rules!"
|
||||||
msgstr "Colobot rządzi!"
|
msgstr "Colobot rządzi!"
|
||||||
|
@ -518,8 +517,11 @@ msgstr "Kurz\\Kurz i bród na robotach i budynkach"
|
||||||
msgid "Dynamic lighting\\Mobile light sources"
|
msgid "Dynamic lighting\\Mobile light sources"
|
||||||
msgstr "Dynamiczne oświetlenie\\Ruchome źródła światła"
|
msgstr "Dynamiczne oświetlenie\\Ruchome źródła światła"
|
||||||
|
|
||||||
|
msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
||||||
|
msgstr "Dynamiczne cienie ++\\Dynamiczne cienie + cienie na obiektach"
|
||||||
|
|
||||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||||
msgstr ""
|
msgstr "Dynamiczne cienie\\Ładne cienie!"
|
||||||
|
|
||||||
msgid "Edit the selected program"
|
msgid "Edit the selected program"
|
||||||
msgstr "Edytuj zaznaczony program"
|
msgstr "Edytuj zaznaczony program"
|
||||||
|
@ -672,9 +674,6 @@ msgstr "Zielony"
|
||||||
msgid "Green flag"
|
msgid "Green flag"
|
||||||
msgstr "Zielona flaga"
|
msgstr "Zielona flaga"
|
||||||
|
|
||||||
msgid "Ground inappropriate"
|
|
||||||
msgstr "Nieodpowiedni teren"
|
|
||||||
|
|
||||||
msgid "Ground not flat enough"
|
msgid "Ground not flat enough"
|
||||||
msgstr "Powierzchnia nie jest wystarczająco płaska"
|
msgstr "Powierzchnia nie jest wystarczająco płaska"
|
||||||
|
|
||||||
|
@ -766,6 +765,9 @@ msgstr "Rozkazy\\Pokazuje rozkazy dotyczące bieżącej misji"
|
||||||
msgid "Internal error - tell the developers"
|
msgid "Internal error - tell the developers"
|
||||||
msgstr "Błąd wewnętrzny - powiadom twórców gry"
|
msgstr "Błąd wewnętrzny - powiadom twórców gry"
|
||||||
|
|
||||||
|
msgid "Invert\\Invert values on this axis"
|
||||||
|
msgstr "Odwróć\\Odwróć wartości na tej osi"
|
||||||
|
|
||||||
msgid "Jet temperature"
|
msgid "Jet temperature"
|
||||||
msgstr "Temperatura silnika"
|
msgstr "Temperatura silnika"
|
||||||
|
|
||||||
|
@ -843,7 +845,7 @@ msgid "Lunar Roving Vehicle"
|
||||||
msgstr "Pojazd Księżycowy"
|
msgstr "Pojazd Księżycowy"
|
||||||
|
|
||||||
msgid "MSAA\\Multisample anti-aliasing"
|
msgid "MSAA\\Multisample anti-aliasing"
|
||||||
msgstr ""
|
msgstr "MSAA\\Multisample anti-aliasing"
|
||||||
|
|
||||||
msgid "Maximize"
|
msgid "Maximize"
|
||||||
msgstr "Powiększ"
|
msgstr "Powiększ"
|
||||||
|
@ -852,7 +854,7 @@ msgid "Minimize"
|
||||||
msgstr "Pomniejsz"
|
msgstr "Pomniejsz"
|
||||||
|
|
||||||
msgid "Mipmap level\\Mipmap level"
|
msgid "Mipmap level\\Mipmap level"
|
||||||
msgstr ""
|
msgstr "Poziom mipmap\\Poziom mipmap"
|
||||||
|
|
||||||
msgid "Mission name"
|
msgid "Mission name"
|
||||||
msgstr "Nazwa misji"
|
msgstr "Nazwa misji"
|
||||||
|
@ -929,9 +931,6 @@ msgstr "Nie ma więcej energii"
|
||||||
msgid "No ore in the subsoil"
|
msgid "No ore in the subsoil"
|
||||||
msgstr "W ziemi nie ma żadnej rudy"
|
msgstr "W ziemi nie ma żadnej rudy"
|
||||||
|
|
||||||
msgid "No other robot"
|
|
||||||
msgstr "Brak innego robota"
|
|
||||||
|
|
||||||
msgid "No power cell"
|
msgid "No power cell"
|
||||||
msgstr "Brak ogniwa elektrycznego"
|
msgstr "Brak ogniwa elektrycznego"
|
||||||
|
|
||||||
|
@ -951,7 +950,7 @@ msgid "No uranium to transform"
|
||||||
msgstr "Brak uranu do przetworzenia"
|
msgstr "Brak uranu do przetworzenia"
|
||||||
|
|
||||||
msgid "No userlevels installed!"
|
msgid "No userlevels installed!"
|
||||||
msgstr ""
|
msgstr "Brak zainstalowanych poziomów użytkownika!"
|
||||||
|
|
||||||
msgid "Normal size"
|
msgid "Normal size"
|
||||||
msgstr "Normalna wielkość"
|
msgstr "Normalna wielkość"
|
||||||
|
@ -971,9 +970,6 @@ msgstr "Wciąż za mało energii"
|
||||||
msgid "Not found anything to destroy"
|
msgid "Not found anything to destroy"
|
||||||
msgstr "Nie znaleziono nic do zniszczenia"
|
msgstr "Nie znaleziono nic do zniszczenia"
|
||||||
|
|
||||||
msgid "Not yet enough energy"
|
|
||||||
msgstr "Wciąż za mało energii"
|
|
||||||
|
|
||||||
msgid "Nothing to analyze"
|
msgid "Nothing to analyze"
|
||||||
msgstr "Nie ma niczego do zanalizowania"
|
msgstr "Nie ma niczego do zanalizowania"
|
||||||
|
|
||||||
|
@ -1013,9 +1009,6 @@ msgstr "OK\\Wybiera zaznaczonego gracza"
|
||||||
msgid "OK\\Close program editor and return to game"
|
msgid "OK\\Close program editor and return to game"
|
||||||
msgstr "OK\\Zamyka edytor programu i powraca do gry"
|
msgstr "OK\\Zamyka edytor programu i powraca do gry"
|
||||||
|
|
||||||
msgid "Object not found"
|
|
||||||
msgstr "Obiekt nieznany"
|
|
||||||
|
|
||||||
msgid "Object too close"
|
msgid "Object too close"
|
||||||
msgstr "Obiekt za blisko"
|
msgstr "Obiekt za blisko"
|
||||||
|
|
||||||
|
@ -1062,6 +1055,9 @@ msgstr "Cząstki w interfejsie\\Para i iskry z silników w interfejsie"
|
||||||
msgid "Paste (Ctrl+v)"
|
msgid "Paste (Ctrl+v)"
|
||||||
msgstr "Wklej (Ctrl+V)"
|
msgstr "Wklej (Ctrl+V)"
|
||||||
|
|
||||||
|
msgid "Pause in background\\Pause the game when the window is unfocused"
|
||||||
|
msgstr "Wstrzymaj w tle\\Wstrzymaj grę gdy okno stanie się nieaktywne"
|
||||||
|
|
||||||
msgid "Pause/continue"
|
msgid "Pause/continue"
|
||||||
msgstr "Pauza/Kontynuuj"
|
msgstr "Pauza/Kontynuuj"
|
||||||
|
|
||||||
|
@ -1186,9 +1182,6 @@ msgstr "Publiczny\\Folder ogólnodostępny"
|
||||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||||
msgstr "Wstrząsy przy wybuchach\\Ekran trzęsie się podczas wybuchów"
|
msgstr "Wstrząsy przy wybuchach\\Ekran trzęsie się podczas wybuchów"
|
||||||
|
|
||||||
msgid "Quality dynamic shadows\\Enable shadow transparency and self shadowing"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Quit\\Quit Colobot: Gold Edition"
|
msgid "Quit\\Quit Colobot: Gold Edition"
|
||||||
msgstr "Wyjdź\\Kończy grę Colobot: Gold Edition"
|
msgstr "Wyjdź\\Kończy grę Colobot: Gold Edition"
|
||||||
|
|
||||||
|
@ -1321,11 +1314,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję"
|
||||||
msgid "Save\\Saves the current mission"
|
msgid "Save\\Saves the current mission"
|
||||||
msgstr "Zapisz\\Zapisuje bieżącą misję"
|
msgstr "Zapisz\\Zapisuje bieżącą misję"
|
||||||
|
|
||||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
|
||||||
msgstr ""
|
|
||||||
"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego "
|
|
||||||
"krawędzi"
|
|
||||||
|
|
||||||
msgid "Select the astronaut\\Selects the astronaut"
|
msgid "Select the astronaut\\Selects the astronaut"
|
||||||
msgstr "Zaznacz astronautę\\Zaznacza astronautę"
|
msgstr "Zaznacz astronautę\\Zaznacza astronautę"
|
||||||
|
|
||||||
|
@ -1334,6 +1322,8 @@ msgstr "Brak średnika na końcu wiersza"
|
||||||
|
|
||||||
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
"Rozdzielczość cieni\\Wyższa wartość oznacza wyższy zasięg i jakość, ale jest "
|
||||||
|
"wolniejsza"
|
||||||
|
|
||||||
msgid "Shield level"
|
msgid "Shield level"
|
||||||
msgstr "Poziom osłony"
|
msgstr "Poziom osłony"
|
||||||
|
@ -1470,9 +1460,6 @@ msgstr "Zestaw przetrwania"
|
||||||
msgid "Switch bots <-> buildings"
|
msgid "Switch bots <-> buildings"
|
||||||
msgstr "Przełącz roboty <-> budynki"
|
msgstr "Przełącz roboty <-> budynki"
|
||||||
|
|
||||||
msgid "System mouse\\Use system mouse cursor"
|
|
||||||
msgstr "Systemowy kursor\\Użyj systemowego kursora myszy"
|
|
||||||
|
|
||||||
msgid "Take off to finish the mission"
|
msgid "Take off to finish the mission"
|
||||||
msgstr "Odleć, aby zakończyć misję"
|
msgstr "Odleć, aby zakończyć misję"
|
||||||
|
|
||||||
|
@ -1486,7 +1473,7 @@ msgid "Terrain relief"
|
||||||
msgstr "Rzeźba terenu"
|
msgstr "Rzeźba terenu"
|
||||||
|
|
||||||
msgid "Texture filtering\\Texture filtering"
|
msgid "Texture filtering\\Texture filtering"
|
||||||
msgstr ""
|
msgstr "Filtrowanie tekstur\\Filtrowanie tekstur"
|
||||||
|
|
||||||
msgid "Textures"
|
msgid "Textures"
|
||||||
msgstr "Tekstury"
|
msgstr "Tekstury"
|
||||||
|
@ -1497,13 +1484,6 @@ msgstr "Wyrażenie musi zwrócić wartość logiczną"
|
||||||
msgid "The function returned no value "
|
msgid "The function returned no value "
|
||||||
msgstr "Funkcja nie zwróciła żadnej wartości "
|
msgstr "Funkcja nie zwróciła żadnej wartości "
|
||||||
|
|
||||||
msgid ""
|
|
||||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
|
||||||
"working.\n"
|
|
||||||
msgstr ""
|
|
||||||
"Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object"
|
|
||||||
"\\radar;.\n"
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||||
msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)"
|
msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)"
|
||||||
|
@ -1528,6 +1508,8 @@ msgstr "Taka etykieta nie istnieje"
|
||||||
|
|
||||||
msgid "This menu is for userlevels from mods, but you didn't install any"
|
msgid "This menu is for userlevels from mods, but you didn't install any"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
"To menu jest przeznaczone na poziomy użytkownika z modyfikacji, ale żadne "
|
||||||
|
"nie są zainstalowane"
|
||||||
|
|
||||||
msgid "This object is not a member of a class"
|
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"
|
||||||
|
@ -1637,9 +1619,6 @@ msgstr "Złoże uranu (miejsce na kopalnię)"
|
||||||
msgid "Uranium ore"
|
msgid "Uranium ore"
|
||||||
msgstr "Ruda uranu"
|
msgstr "Ruda uranu"
|
||||||
|
|
||||||
msgid "Use a joystick\\Joystick or keyboard"
|
|
||||||
msgstr "Używaj joysticka\\Joystick lub klawiatura"
|
|
||||||
|
|
||||||
msgid "User levels"
|
msgid "User levels"
|
||||||
msgstr "Poziomy użytkownika"
|
msgstr "Poziomy użytkownika"
|
||||||
|
|
||||||
|
@ -1829,39 +1808,30 @@ msgstr "\\Fioletowe flagi"
|
||||||
msgid "\\Yellow flags"
|
msgid "\\Yellow flags"
|
||||||
msgstr "\\Żółte flagi"
|
msgstr "\\Żółte flagi"
|
||||||
|
|
||||||
msgid "\\b;Aliens\n"
|
msgid "colobot.info"
|
||||||
msgstr "\\b;Obcy\n"
|
msgstr "colobot.info"
|
||||||
|
|
||||||
msgid "\\b;Buildings\n"
|
msgid "epsitec.com"
|
||||||
msgstr "\\b;Budynki\n"
|
msgstr "epsitec.com"
|
||||||
|
|
||||||
msgid "\\b;Error\n"
|
#~ msgid " Drivers:"
|
||||||
msgstr "\\b;Błąd\n"
|
#~ msgstr " Sterowniki:"
|
||||||
|
|
||||||
msgid "\\b;List of objects\n"
|
|
||||||
msgstr "\\b;Lista obiektów\n"
|
|
||||||
|
|
||||||
msgid "\\b;Moveable objects\n"
|
|
||||||
msgstr "\\b;Obiekty ruchome\n"
|
|
||||||
|
|
||||||
msgid "\\b;Robots\n"
|
|
||||||
msgstr "\\b;Roboty\n"
|
|
||||||
|
|
||||||
msgid "\\c; (none)\\n;\n"
|
|
||||||
msgstr "\\c; (brak)\\n;\n"
|
|
||||||
|
|
||||||
msgid "www.colobot.info"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "www.epsitec.com"
|
|
||||||
msgstr "www.epsitec.com"
|
|
||||||
|
|
||||||
#~ msgid "3D sound\\3D positioning of the sound"
|
#~ msgid "3D sound\\3D positioning of the sound"
|
||||||
#~ msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
|
#~ msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
|
||||||
|
|
||||||
|
#~ msgid "Building too close"
|
||||||
|
#~ msgstr "Budynek za blisko"
|
||||||
|
|
||||||
|
#~ msgid "Can not create this; there are too many objects"
|
||||||
|
#~ msgstr "Nie można tego utworzyć, za dużo obiektów"
|
||||||
|
|
||||||
#~ msgid "Cancel\\Keep current player name"
|
#~ msgid "Cancel\\Keep current player name"
|
||||||
#~ msgstr "Anuluj\\Zachowuje bieżące imię gracza"
|
#~ msgstr "Anuluj\\Zachowuje bieżące imię gracza"
|
||||||
|
|
||||||
|
#~ msgid "Checkpoint crossed"
|
||||||
|
#~ msgstr "Przekroczono punkt kontrolny"
|
||||||
|
|
||||||
#~ msgid "Compass"
|
#~ msgid "Compass"
|
||||||
#~ msgstr "Kompas"
|
#~ msgstr "Kompas"
|
||||||
|
|
||||||
|
@ -1883,6 +1853,9 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
||||||
#~ msgstr "Przyjacielski ogień\\Własne strzały uszkadzają Twoje obiekty"
|
#~ msgstr "Przyjacielski ogień\\Własne strzały uszkadzają Twoje obiekty"
|
||||||
|
|
||||||
|
#~ msgid "Ground inappropriate"
|
||||||
|
#~ msgstr "Nieodpowiedni teren"
|
||||||
|
|
||||||
#~ msgid "Key word help\\More detailed help about key words"
|
#~ msgid "Key word help\\More detailed help about key words"
|
||||||
#~ msgstr ""
|
#~ msgstr ""
|
||||||
#~ "Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
|
#~ "Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
|
||||||
|
@ -1896,10 +1869,19 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
||||||
#~ msgstr "Cień kursora myszy\\Dodaje cień kursorowi myszy"
|
#~ msgstr "Cień kursora myszy\\Dodaje cień kursorowi myszy"
|
||||||
|
|
||||||
|
#~ msgid "No other robot"
|
||||||
|
#~ msgstr "Brak innego robota"
|
||||||
|
|
||||||
|
#~ msgid "Not yet enough energy"
|
||||||
|
#~ msgstr "Wciąż za mało energii"
|
||||||
|
|
||||||
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
||||||
#~ msgstr ""
|
#~ msgstr ""
|
||||||
#~ "Ilość elementów dekoracyjnych \\Ilość elementów czysto dekoracyjnych"
|
#~ "Ilość elementów dekoracyjnych \\Ilość elementów czysto dekoracyjnych"
|
||||||
|
|
||||||
|
#~ msgid "Object not found"
|
||||||
|
#~ msgstr "Obiekt nieznany"
|
||||||
|
|
||||||
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
||||||
#~ msgstr "Planety i gwiazdy\\Obiekty astronomiczne na niebie"
|
#~ msgstr "Planety i gwiazdy\\Obiekty astronomiczne na niebie"
|
||||||
|
|
||||||
|
@ -1915,5 +1897,39 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Sunbeams\\Sunbeams in the sky"
|
#~ msgid "Sunbeams\\Sunbeams in the sky"
|
||||||
#~ msgstr "Promienie słoneczne\\Promienie słoneczne na niebie"
|
#~ msgstr "Promienie słoneczne\\Promienie słoneczne na niebie"
|
||||||
|
|
||||||
|
#~ msgid "System mouse\\Use system mouse cursor"
|
||||||
|
#~ msgstr "Systemowy kursor\\Użyj systemowego kursora myszy"
|
||||||
|
|
||||||
#~ msgid "Textures\\Quality of textures "
|
#~ msgid "Textures\\Quality of textures "
|
||||||
#~ msgstr "Tekstury\\Jakość tekstur "
|
#~ msgstr "Tekstury\\Jakość tekstur "
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||||
|
#~ "working.\n"
|
||||||
|
#~ msgstr ""
|
||||||
|
#~ "Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object"
|
||||||
|
#~ "\\radar;.\n"
|
||||||
|
|
||||||
|
#~ msgid "Use a joystick\\Joystick or keyboard"
|
||||||
|
#~ msgstr "Używaj joysticka\\Joystick lub klawiatura"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Aliens\n"
|
||||||
|
#~ msgstr "\\b;Obcy\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Buildings\n"
|
||||||
|
#~ msgstr "\\b;Budynki\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Error\n"
|
||||||
|
#~ msgstr "\\b;Błąd\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;List of objects\n"
|
||||||
|
#~ msgstr "\\b;Lista obiektów\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Moveable objects\n"
|
||||||
|
#~ msgstr "\\b;Obiekty ruchome\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Robots\n"
|
||||||
|
#~ msgstr "\\b;Roboty\n"
|
||||||
|
|
||||||
|
#~ msgid "\\c; (none)\\n;\n"
|
||||||
|
#~ msgstr "\\c; (brak)\\n;\n"
|
||||||
|
|
140
po/ru.po
140
po/ru.po
|
@ -28,9 +28,6 @@ msgstr " Разделы:"
|
||||||
msgid " Custom levels:"
|
msgid " Custom levels:"
|
||||||
msgstr " Пользовательские уровни:"
|
msgstr " Пользовательские уровни:"
|
||||||
|
|
||||||
msgid " Drivers:"
|
|
||||||
msgstr " Драйверы:"
|
|
||||||
|
|
||||||
msgid " Exercises in the chapter:"
|
msgid " Exercises in the chapter:"
|
||||||
msgstr " Упражнения в разделе:"
|
msgstr " Упражнения в разделе:"
|
||||||
|
|
||||||
|
@ -314,9 +311,6 @@ msgstr "Здание построено"
|
||||||
msgid "Building destroyed"
|
msgid "Building destroyed"
|
||||||
msgstr "Здание разрушено"
|
msgstr "Здание разрушено"
|
||||||
|
|
||||||
msgid "Building too close"
|
|
||||||
msgstr "Здание слишком близко"
|
|
||||||
|
|
||||||
msgid "Button %1"
|
msgid "Button %1"
|
||||||
msgstr "Кнопка %1"
|
msgstr "Кнопка %1"
|
||||||
|
|
||||||
|
@ -332,6 +326,12 @@ msgstr "Отдалить камеру"
|
||||||
msgid "Camera back\\Moves the camera backward"
|
msgid "Camera back\\Moves the camera backward"
|
||||||
msgstr "Отдалить камеру\\Перемещение камеры назад"
|
msgstr "Отдалить камеру\\Перемещение камеры назад"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
"Camera border scrolling\\Scrolling when the mouse touches right or left "
|
||||||
|
"border"
|
||||||
|
msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана"
|
||||||
|
|
||||||
msgid "Camera closer\\Moves the camera forward"
|
msgid "Camera closer\\Moves the camera forward"
|
||||||
msgstr "Приблизать камеру\\Перемещение камеры вперед"
|
msgstr "Приблизать камеру\\Перемещение камеры вперед"
|
||||||
|
|
||||||
|
@ -350,9 +350,6 @@ msgstr "Камеру вправо"
|
||||||
msgid "Camera up\\Increase camera angle while visiting message origin"
|
msgid "Camera up\\Increase camera angle while visiting message origin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Can not create this; there are too many objects"
|
|
||||||
msgstr "Не удается это создать, слишком много объектов"
|
|
||||||
|
|
||||||
msgid "Can not produce not researched object"
|
msgid "Can not produce not researched object"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -380,12 +377,12 @@ msgstr "Изменить вид\\Переключение между борто
|
||||||
msgid "Change player\\Change player"
|
msgid "Change player\\Change player"
|
||||||
msgstr "Новый игрок\\Выберите имя для игрока"
|
msgstr "Новый игрок\\Выберите имя для игрока"
|
||||||
|
|
||||||
|
msgid "Cheat console\\Show cheat console"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Checkpoint"
|
msgid "Checkpoint"
|
||||||
msgstr "Контрольная точка"
|
msgstr "Контрольная точка"
|
||||||
|
|
||||||
msgid "Checkpoint crossed"
|
|
||||||
msgstr "Вы прошли контрольную точку"
|
|
||||||
|
|
||||||
msgid "Climb\\Increases the power of the jet"
|
msgid "Climb\\Increases the power of the jet"
|
||||||
msgstr "Взлет и подъем\\Увеличивает мощность реактивного двигателя"
|
msgstr "Взлет и подъем\\Увеличивает мощность реактивного двигателя"
|
||||||
|
|
||||||
|
@ -512,6 +509,9 @@ msgstr "Пыль\\Пыль и грязь на ботах и зданиях"
|
||||||
msgid "Dynamic lighting\\Mobile light sources"
|
msgid "Dynamic lighting\\Mobile light sources"
|
||||||
msgstr "Динамическое освещение\\Подвижные источники света"
|
msgstr "Динамическое освещение\\Подвижные источники света"
|
||||||
|
|
||||||
|
msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -666,9 +666,6 @@ msgstr "Зеленый"
|
||||||
msgid "Green flag"
|
msgid "Green flag"
|
||||||
msgstr "Зеленый флаг"
|
msgstr "Зеленый флаг"
|
||||||
|
|
||||||
msgid "Ground inappropriate"
|
|
||||||
msgstr "Земля не подходит"
|
|
||||||
|
|
||||||
msgid "Ground not flat enough"
|
msgid "Ground not flat enough"
|
||||||
msgstr "Земля недостаточно плоская"
|
msgstr "Земля недостаточно плоская"
|
||||||
|
|
||||||
|
@ -759,6 +756,9 @@ msgstr "Инструкции\\Показывает инструкции по т
|
||||||
msgid "Internal error - tell the developers"
|
msgid "Internal error - tell the developers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Invert\\Invert values on this axis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Jet temperature"
|
msgid "Jet temperature"
|
||||||
msgstr "Температура реактивного двигателя"
|
msgstr "Температура реактивного двигателя"
|
||||||
|
|
||||||
|
@ -925,9 +925,6 @@ msgstr "Нет энергии"
|
||||||
msgid "No ore in the subsoil"
|
msgid "No ore in the subsoil"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "No other robot"
|
|
||||||
msgstr "Нет робота"
|
|
||||||
|
|
||||||
msgid "No power cell"
|
msgid "No power cell"
|
||||||
msgstr "Нет батареи"
|
msgstr "Нет батареи"
|
||||||
|
|
||||||
|
@ -967,9 +964,6 @@ msgstr "Не хватает энергии"
|
||||||
msgid "Not found anything to destroy"
|
msgid "Not found anything to destroy"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Not yet enough energy"
|
|
||||||
msgstr "Не хватает энергии"
|
|
||||||
|
|
||||||
msgid "Nothing to analyze"
|
msgid "Nothing to analyze"
|
||||||
msgstr "Нечего анализировать"
|
msgstr "Нечего анализировать"
|
||||||
|
|
||||||
|
@ -1009,9 +1003,6 @@ msgstr "ОК\\Выбрать игрока"
|
||||||
msgid "OK\\Close program editor and return to game"
|
msgid "OK\\Close program editor and return to game"
|
||||||
msgstr "ОК\\Закрыть редактор программ и вернуться к игре"
|
msgstr "ОК\\Закрыть редактор программ и вернуться к игре"
|
||||||
|
|
||||||
msgid "Object not found"
|
|
||||||
msgstr "Объект не найден"
|
|
||||||
|
|
||||||
msgid "Object too close"
|
msgid "Object too close"
|
||||||
msgstr "Объект слишком близок"
|
msgstr "Объект слишком близок"
|
||||||
|
|
||||||
|
@ -1059,6 +1050,9 @@ msgstr "Частицы в интерфейсе меню\\Пар из труб и
|
||||||
msgid "Paste (Ctrl+v)"
|
msgid "Paste (Ctrl+v)"
|
||||||
msgstr "Вставить (Ctrl+V)"
|
msgstr "Вставить (Ctrl+V)"
|
||||||
|
|
||||||
|
msgid "Pause in background\\Pause the game when the window is unfocused"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Pause/continue"
|
msgid "Pause/continue"
|
||||||
msgstr "Пауза/продолжить"
|
msgstr "Пауза/продолжить"
|
||||||
|
|
||||||
|
@ -1184,9 +1178,6 @@ msgstr "Общее\\Общая папка"
|
||||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||||
msgstr "Землетряс. при взрывах\\Тряска экрана при взрывах"
|
msgstr "Землетряс. при взрывах\\Тряска экрана при взрывах"
|
||||||
|
|
||||||
msgid "Quality dynamic shadows\\Enable shadow transparency and self shadowing"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Quit\\Quit Colobot: Gold Edition"
|
msgid "Quit\\Quit Colobot: Gold Edition"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1321,9 +1312,6 @@ msgstr "Сохранить\\Сохранить текущую миссию"
|
||||||
msgid "Save\\Saves the current mission"
|
msgid "Save\\Saves the current mission"
|
||||||
msgstr "Сохранить\\Сохранить текущую миссию"
|
msgstr "Сохранить\\Сохранить текущую миссию"
|
||||||
|
|
||||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
|
||||||
msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана"
|
|
||||||
|
|
||||||
msgid "Select the astronaut\\Selects the astronaut"
|
msgid "Select the astronaut\\Selects the astronaut"
|
||||||
msgstr "Выбор астронавта\\Выбор астронавта"
|
msgstr "Выбор астронавта\\Выбор астронавта"
|
||||||
|
|
||||||
|
@ -1470,9 +1458,6 @@ msgstr "Аптечка"
|
||||||
msgid "Switch bots <-> buildings"
|
msgid "Switch bots <-> buildings"
|
||||||
msgstr "Переключение между ботами и зданиями"
|
msgstr "Переключение между ботами и зданиями"
|
||||||
|
|
||||||
msgid "System mouse\\Use system mouse cursor"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Take off to finish the mission"
|
msgid "Take off to finish the mission"
|
||||||
msgstr "Взлететь, чтобы закончить миссию"
|
msgstr "Взлететь, чтобы закончить миссию"
|
||||||
|
|
||||||
|
@ -1497,12 +1482,6 @@ msgstr "Выражение должно возвращать логическо
|
||||||
msgid "The function returned no value "
|
msgid "The function returned no value "
|
||||||
msgstr "Функция не возвратила значения"
|
msgstr "Функция не возвратила значения"
|
||||||
|
|
||||||
msgid ""
|
|
||||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
|
||||||
"working.\n"
|
|
||||||
msgstr ""
|
|
||||||
"Список доступен только если \\l;radar station\\u object\\radar; работают\n"
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -1637,9 +1616,6 @@ msgstr "Запасы урана (место для буровой вышки)"
|
||||||
msgid "Uranium ore"
|
msgid "Uranium ore"
|
||||||
msgstr "Урановая руда"
|
msgstr "Урановая руда"
|
||||||
|
|
||||||
msgid "Use a joystick\\Joystick or keyboard"
|
|
||||||
msgstr "Использовать джойстик\\Джойстик или клавиатура"
|
|
||||||
|
|
||||||
msgid "User levels"
|
msgid "User levels"
|
||||||
msgstr "Пользовательские уровни"
|
msgstr "Пользовательские уровни"
|
||||||
|
|
||||||
|
@ -1829,48 +1805,40 @@ msgstr "\\Фиолетовый флаг"
|
||||||
msgid "\\Yellow flags"
|
msgid "\\Yellow flags"
|
||||||
msgstr "\\Желтый флаг"
|
msgstr "\\Желтый флаг"
|
||||||
|
|
||||||
msgid "\\b;Aliens\n"
|
msgid "colobot.info"
|
||||||
msgstr "\\b;Чужаки\n"
|
|
||||||
|
|
||||||
msgid "\\b;Buildings\n"
|
|
||||||
msgstr "\\b;Здания\n"
|
|
||||||
|
|
||||||
msgid "\\b;Error\n"
|
|
||||||
msgstr "\\b;Ошибка\n"
|
|
||||||
|
|
||||||
msgid "\\b;List of objects\n"
|
|
||||||
msgstr "\\b;Список объектов\n"
|
|
||||||
|
|
||||||
msgid "\\b;Moveable objects\n"
|
|
||||||
msgstr "\\b;Подвижные объекты\n"
|
|
||||||
|
|
||||||
msgid "\\b;Robots\n"
|
|
||||||
msgstr "\\b;Роботы\n"
|
|
||||||
|
|
||||||
msgid "\\c; (none)\\n;\n"
|
|
||||||
msgstr "\\c; (нет)\\n;\n"
|
|
||||||
|
|
||||||
msgid "www.colobot.info"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "www.epsitec.com"
|
#, fuzzy
|
||||||
|
msgid "epsitec.com"
|
||||||
msgstr "www.epsitec.com"
|
msgstr "www.epsitec.com"
|
||||||
|
|
||||||
#~ msgid " "
|
#~ msgid " "
|
||||||
#~ msgstr " "
|
#~ msgstr " "
|
||||||
|
|
||||||
|
#~ msgid " Drivers:"
|
||||||
|
#~ msgstr " Драйверы:"
|
||||||
|
|
||||||
#~ msgid " Missions on this level:"
|
#~ msgid " Missions on this level:"
|
||||||
#~ msgstr " Миссии на этом уровне:"
|
#~ msgstr " Миссии на этом уровне:"
|
||||||
|
|
||||||
#~ msgid "3D sound\\3D positioning of the sound"
|
#~ msgid "3D sound\\3D positioning of the sound"
|
||||||
#~ msgstr "3D-звук\\Стерео звук"
|
#~ msgstr "3D-звук\\Стерео звук"
|
||||||
|
|
||||||
|
#~ msgid "Building too close"
|
||||||
|
#~ msgstr "Здание слишком близко"
|
||||||
|
|
||||||
#~ msgid "COLOBOT"
|
#~ msgid "COLOBOT"
|
||||||
#~ msgstr "КОЛОБОТ"
|
#~ msgstr "КОЛОБОТ"
|
||||||
|
|
||||||
|
#~ msgid "Can not create this; there are too many objects"
|
||||||
|
#~ msgstr "Не удается это создать, слишком много объектов"
|
||||||
|
|
||||||
#~ msgid "Cancel\\Keep current player name"
|
#~ msgid "Cancel\\Keep current player name"
|
||||||
#~ msgstr "Отмена\\Отмена"
|
#~ msgstr "Отмена\\Отмена"
|
||||||
|
|
||||||
|
#~ msgid "Checkpoint crossed"
|
||||||
|
#~ msgstr "Вы прошли контрольную точку"
|
||||||
|
|
||||||
#~ msgid "Compass"
|
#~ msgid "Compass"
|
||||||
#~ msgstr "Компас"
|
#~ msgstr "Компас"
|
||||||
|
|
||||||
|
@ -1896,6 +1864,9 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
#~ msgid "Friendly fire\\Your shooting can damage your own objects "
|
||||||
#~ msgstr "Огонь по своим\\Вы можете повредить собственные объекты"
|
#~ msgstr "Огонь по своим\\Вы можете повредить собственные объекты"
|
||||||
|
|
||||||
|
#~ msgid "Ground inappropriate"
|
||||||
|
#~ msgstr "Земля не подходит"
|
||||||
|
|
||||||
#~ msgid "Key word help\\More detailed help about key words"
|
#~ msgid "Key word help\\More detailed help about key words"
|
||||||
#~ msgstr "Помощь по командам\\Более подробная справку по командам"
|
#~ msgstr "Помощь по командам\\Более подробная справку по командам"
|
||||||
|
|
||||||
|
@ -1905,9 +1876,18 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
|
||||||
#~ msgstr "Тень мыши\\Мышь отбрасывает тень"
|
#~ msgstr "Тень мыши\\Мышь отбрасывает тень"
|
||||||
|
|
||||||
|
#~ msgid "No other robot"
|
||||||
|
#~ msgstr "Нет робота"
|
||||||
|
|
||||||
|
#~ msgid "Not yet enough energy"
|
||||||
|
#~ msgstr "Не хватает энергии"
|
||||||
|
|
||||||
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
#~ msgid "Num of decorative objects\\Number of purely ornamental objects"
|
||||||
#~ msgstr "Количество декораций\\Количество декоративных объектов"
|
#~ msgstr "Количество декораций\\Количество декоративных объектов"
|
||||||
|
|
||||||
|
#~ msgid "Object not found"
|
||||||
|
#~ msgstr "Объект не найден"
|
||||||
|
|
||||||
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
#~ msgid "Planets and stars\\Astronomical objects in the sky"
|
||||||
#~ msgstr "Планеты и звезды\\Астрономические объекты в небе"
|
#~ msgstr "Планеты и звезды\\Астрономические объекты в небе"
|
||||||
|
|
||||||
|
@ -1932,8 +1912,38 @@ msgstr "www.epsitec.com"
|
||||||
#~ msgid "Textures\\Quality of textures "
|
#~ msgid "Textures\\Quality of textures "
|
||||||
#~ msgstr "Текстуры\\Качество текстур "
|
#~ msgstr "Текстуры\\Качество текстур "
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||||
|
#~ "working.\n"
|
||||||
|
#~ msgstr ""
|
||||||
|
#~ "Список доступен только если \\l;radar station\\u object\\radar; работают\n"
|
||||||
|
|
||||||
|
#~ msgid "Use a joystick\\Joystick or keyboard"
|
||||||
|
#~ msgstr "Использовать джойстик\\Джойстик или клавиатура"
|
||||||
|
|
||||||
#~ msgid "User\\User levels"
|
#~ msgid "User\\User levels"
|
||||||
#~ msgstr "Польз.\\Пользовательские уровни"
|
#~ msgstr "Польз.\\Пользовательские уровни"
|
||||||
|
|
||||||
#~ msgid "\\Return to COLOBOT"
|
#~ msgid "\\Return to COLOBOT"
|
||||||
#~ msgstr "\\Вернуться в COLOBOT"
|
#~ msgstr "\\Вернуться в COLOBOT"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Aliens\n"
|
||||||
|
#~ msgstr "\\b;Чужаки\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Buildings\n"
|
||||||
|
#~ msgstr "\\b;Здания\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Error\n"
|
||||||
|
#~ msgstr "\\b;Ошибка\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;List of objects\n"
|
||||||
|
#~ msgstr "\\b;Список объектов\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Moveable objects\n"
|
||||||
|
#~ msgstr "\\b;Подвижные объекты\n"
|
||||||
|
|
||||||
|
#~ msgid "\\b;Robots\n"
|
||||||
|
#~ msgstr "\\b;Роботы\n"
|
||||||
|
|
||||||
|
#~ msgid "\\c; (none)\\n;\n"
|
||||||
|
#~ msgstr "\\c; (нет)\\n;\n"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
libCBot.so
|
|
3967
src/CBot/CBot.cpp
3967
src/CBot/CBot.cpp
File diff suppressed because it is too large
Load Diff
1689
src/CBot/CBot.h
1689
src/CBot/CBot.h
File diff suppressed because it is too large
Load Diff
|
@ -1,146 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
|
||||||
* Copyright (C) 2001-2015, 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
|
||||||
// expressions of type Operand1 + Operand2
|
|
||||||
// Operand1 - Operand2
|
|
||||||
|
|
||||||
#include "CBot.h"
|
|
||||||
|
|
||||||
// various constructors
|
|
||||||
|
|
||||||
CBotAddExpr::CBotAddExpr()
|
|
||||||
{
|
|
||||||
m_leftop =
|
|
||||||
m_rightop = nullptr; // nullptr to be able to delete without further
|
|
||||||
name = "CBotAddExpr"; // debug
|
|
||||||
}
|
|
||||||
|
|
||||||
CBotAddExpr::~CBotAddExpr()
|
|
||||||
{
|
|
||||||
delete m_leftop;
|
|
||||||
delete m_rightop;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// compile une instruction de type A + B
|
|
||||||
|
|
||||||
CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack)
|
|
||||||
{
|
|
||||||
CBotStack* pStk = pStack->TokenStack(); // one end of stack please
|
|
||||||
|
|
||||||
// looking statements that may be suitable to the left of the operation + or -
|
|
||||||
|
|
||||||
CBotInstr* left = CBotMulExpr::Compile( p, pStk ); // expression A * B left
|
|
||||||
if (left == nullptr) return pStack->Return(nullptr, pStk); // if error, transmit
|
|
||||||
|
|
||||||
// do we have the token + or - next?
|
|
||||||
|
|
||||||
if ( p->GetType() == ID_ADD ||
|
|
||||||
p->GetType() == ID_SUB) // more or less
|
|
||||||
{
|
|
||||||
CBotAddExpr* inst = new CBotAddExpr(); // element for operation
|
|
||||||
inst->SetToken(p); // stores the operation
|
|
||||||
|
|
||||||
int type1, type2;
|
|
||||||
type1 = pStack->GetType(); // what kind of the first operand?
|
|
||||||
|
|
||||||
p = p->Next(); // skip the token of the operation
|
|
||||||
|
|
||||||
// looking statements that may be suitable for right
|
|
||||||
|
|
||||||
if ( nullptr != (inst->m_rightop = CBotAddExpr::Compile( p, pStk )) ) // expression (...) rigth
|
|
||||||
{
|
|
||||||
// there is an acceptable second operand
|
|
||||||
|
|
||||||
type2 = pStack->GetType(); // what kind of results?
|
|
||||||
|
|
||||||
if ( type1 == type2 ) // are the results consistent ?
|
|
||||||
{
|
|
||||||
// ok so, saves the operand in the object
|
|
||||||
inst->m_leftop = left;
|
|
||||||
// and makes the object on demand
|
|
||||||
return pStack->Return(inst, pStk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// in case of error, free the elements
|
|
||||||
delete left;
|
|
||||||
delete inst;
|
|
||||||
// and transmits the error that is on the stack
|
|
||||||
return pStack->Return(nullptr, pStk);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we are not dealing with an operation + or -
|
|
||||||
// goes to that requested, the operand (left) found
|
|
||||||
// place the object "addition"
|
|
||||||
return pStack->Return(left, pStk);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// operation is addition or subtraction
|
|
||||||
|
|
||||||
bool CBotAddExpr::Execute(CBotStack* &pStack)
|
|
||||||
{
|
|
||||||
CBotStack* pStk1 = pStack->AddStack(this); // adds an item to the stack
|
|
||||||
// or is found in case of recovery
|
|
||||||
// if ( pSk1 == EOX ) return TRUE;
|
|
||||||
|
|
||||||
|
|
||||||
// according to recovery, it may be in one of two states
|
|
||||||
|
|
||||||
if ( pStk1->GetState() == 0 && // first state, evaluates the left operand
|
|
||||||
!m_leftop->Execute(pStk1) ) return FALSE; // interrupted here?
|
|
||||||
|
|
||||||
// passes to the next step
|
|
||||||
pStk1->SetState(1); // ready for further
|
|
||||||
|
|
||||||
// requires a little more stack to not touch the result of the left
|
|
||||||
// which is on the stack, precisely.
|
|
||||||
|
|
||||||
CBotStack* pStk2 = pStk1->AddStack(); // adds an item to the stack
|
|
||||||
// or is found in case of recovery
|
|
||||||
|
|
||||||
// Second state, evaluates the right operand
|
|
||||||
if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrupted here?
|
|
||||||
|
|
||||||
int type1 = pStk1->GetType(); // what kind of results?
|
|
||||||
int type2 = pStk2->GetType();
|
|
||||||
|
|
||||||
// creates a temporary variable to put the result
|
|
||||||
CBotVar* result = new CBotVar( nullptr, MAX(type1, type2));
|
|
||||||
|
|
||||||
// is the operation as requested
|
|
||||||
switch (GetTokenType())
|
|
||||||
{
|
|
||||||
case ID_ADD:
|
|
||||||
result->Add(pStk1->GetVar(), pStk2->GetVar()); // addition
|
|
||||||
break;
|
|
||||||
case ID_SUB:
|
|
||||||
result->Sub(pStk1->GetVar(), pStk2->GetVar()); // subtraction
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pStk2->SetVar(result); // puts the result on the stack
|
|
||||||
|
|
||||||
pStk1->Return(pStk2); // frees the stack
|
|
||||||
return pStack->Return(pStk1); // transmits the result
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,397 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotToken.h"
|
||||||
|
#include "CBot/CBotExternalCall.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotFunction.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotProgram* CBotCStack::m_prog = nullptr; // init the static variable
|
||||||
|
CBotError CBotCStack::m_error = CBotNoErr;
|
||||||
|
int CBotCStack::m_end = 0;
|
||||||
|
CBotTypResult CBotCStack::m_retTyp = CBotTypResult(0);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCStack::CBotCStack(CBotCStack* ppapa)
|
||||||
|
{
|
||||||
|
m_next = nullptr;
|
||||||
|
m_prev = ppapa;
|
||||||
|
|
||||||
|
if (ppapa == nullptr)
|
||||||
|
{
|
||||||
|
m_error = CBotNoErr;
|
||||||
|
m_start = 0;
|
||||||
|
m_end = 0;
|
||||||
|
m_bBlock = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_start = ppapa->m_start;
|
||||||
|
m_bBlock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_listVar = nullptr;
|
||||||
|
m_var = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCStack::~CBotCStack()
|
||||||
|
{
|
||||||
|
if (m_next != nullptr) delete m_next;
|
||||||
|
if (m_prev != nullptr) m_prev->m_next = nullptr; // removes chain
|
||||||
|
|
||||||
|
delete m_var;
|
||||||
|
delete m_listVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
|
||||||
|
{
|
||||||
|
if (m_next != nullptr) return m_next; // include on an existing stack
|
||||||
|
|
||||||
|
CBotCStack* p = new CBotCStack(this);
|
||||||
|
m_next = p; // channel element
|
||||||
|
p->m_bBlock = bBlock;
|
||||||
|
|
||||||
|
if (pToken != nullptr) p->SetStartError(pToken->GetStart());
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
|
||||||
|
{
|
||||||
|
if ( pfils == this ) return inst;
|
||||||
|
|
||||||
|
if (m_var != nullptr) delete m_var; // value replaced?
|
||||||
|
m_var = pfils->m_var; // result transmitted
|
||||||
|
pfils->m_var = nullptr; // not to destroy the variable
|
||||||
|
|
||||||
|
if (m_error)
|
||||||
|
{
|
||||||
|
m_start = pfils->m_start; // retrieves the position of the error
|
||||||
|
m_end = pfils->m_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete pfils;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
|
||||||
|
{
|
||||||
|
if (m_var != nullptr) delete m_var; // value replaced?
|
||||||
|
m_var = pfils->m_var; // result transmitted
|
||||||
|
pfils->m_var = nullptr; // not to destroy the variable
|
||||||
|
|
||||||
|
if (m_error)
|
||||||
|
{
|
||||||
|
m_start = pfils->m_start; // retrieves the position of the error
|
||||||
|
m_end = pfils->m_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete pfils;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotError CBotCStack::GetError(int& start, int& end)
|
||||||
|
{
|
||||||
|
start = m_start;
|
||||||
|
end = m_end;
|
||||||
|
return m_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotError CBotCStack::GetError()
|
||||||
|
{
|
||||||
|
return m_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotTypResult CBotCStack::GetTypResult(CBotVar::GetTypeMode mode)
|
||||||
|
{
|
||||||
|
if (m_var == nullptr)
|
||||||
|
return CBotTypResult(99);
|
||||||
|
return m_var->GetTypResult(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CBotCStack::GetType(CBotVar::GetTypeMode mode)
|
||||||
|
{
|
||||||
|
if (m_var == nullptr)
|
||||||
|
return 99;
|
||||||
|
return m_var->GetType(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotClass* CBotCStack::GetClass()
|
||||||
|
{
|
||||||
|
if ( m_var == nullptr )
|
||||||
|
return nullptr;
|
||||||
|
if ( m_var->GetType(CBotVar::GetTypeMode::CLASS_AS_POINTER) != CBotTypPointer ) return nullptr;
|
||||||
|
|
||||||
|
return m_var->GetClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetType(CBotTypResult& type)
|
||||||
|
{
|
||||||
|
if (m_var == nullptr) return;
|
||||||
|
m_var->SetType( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
|
||||||
|
{
|
||||||
|
CBotCStack* p = this;
|
||||||
|
std::string name = pToken->GetString();
|
||||||
|
|
||||||
|
while (p != nullptr)
|
||||||
|
{
|
||||||
|
CBotVar* pp = p->m_listVar;
|
||||||
|
while ( pp != nullptr)
|
||||||
|
{
|
||||||
|
if (name == pp->GetName())
|
||||||
|
{
|
||||||
|
return pp;
|
||||||
|
}
|
||||||
|
pp = pp->m_next;
|
||||||
|
}
|
||||||
|
p = p->m_prev;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotVar* CBotCStack::FindVar(CBotToken& Token)
|
||||||
|
{
|
||||||
|
CBotToken* pt = &Token;
|
||||||
|
return FindVar(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotVar* CBotCStack::CopyVar(CBotToken& Token)
|
||||||
|
{
|
||||||
|
CBotVar* pVar = FindVar( Token );
|
||||||
|
|
||||||
|
if ( pVar == nullptr) return nullptr;
|
||||||
|
|
||||||
|
CBotVar* pCopy = CBotVar::Create( "", pVar->GetType() );
|
||||||
|
pCopy->Copy(pVar);
|
||||||
|
return pCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCStack::IsOk()
|
||||||
|
{
|
||||||
|
return (m_error == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetStartError( int pos )
|
||||||
|
{
|
||||||
|
if ( m_error != 0) return; // does not change existing error
|
||||||
|
m_start = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetError(CBotError n, int pos)
|
||||||
|
{
|
||||||
|
if ( n!= 0 && m_error != 0) return; // does not change existing error
|
||||||
|
m_error = n;
|
||||||
|
m_end = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetError(CBotError n, CBotToken* p)
|
||||||
|
{
|
||||||
|
if (m_error) return; // does not change existing error
|
||||||
|
m_error = n;
|
||||||
|
m_start = p->GetStart();
|
||||||
|
m_end = p->GetEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::ResetError(CBotError n, int start, int end)
|
||||||
|
{
|
||||||
|
m_error = n;
|
||||||
|
m_start = start;
|
||||||
|
m_end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCStack::NextToken(CBotToken* &p)
|
||||||
|
{
|
||||||
|
CBotToken* pp = p;
|
||||||
|
|
||||||
|
p = p->GetNext();
|
||||||
|
if (p!=nullptr) return true;
|
||||||
|
|
||||||
|
SetError(CBotErrNoTerminator, pp->GetEnd());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetProgram(CBotProgram* p)
|
||||||
|
{
|
||||||
|
m_prog = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotProgram* CBotCStack::GetProgram()
|
||||||
|
{
|
||||||
|
return m_prog;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetRetType(CBotTypResult& type)
|
||||||
|
{
|
||||||
|
m_retTyp = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotTypResult CBotCStack::GetRetType()
|
||||||
|
{
|
||||||
|
return m_retTyp;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetVar( CBotVar* var )
|
||||||
|
{
|
||||||
|
if (m_var) delete m_var; // replacement of a variable
|
||||||
|
m_var = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::SetCopyVar( CBotVar* var )
|
||||||
|
{
|
||||||
|
if (m_var) delete m_var; // replacement of a variable
|
||||||
|
|
||||||
|
if ( var == nullptr ) return;
|
||||||
|
m_var = CBotVar::Create("", var->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
|
||||||
|
m_var->Copy( var );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotVar* CBotCStack::GetVar()
|
||||||
|
{
|
||||||
|
return m_var;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::AddVar(CBotVar* pVar)
|
||||||
|
{
|
||||||
|
CBotCStack* p = this;
|
||||||
|
|
||||||
|
// returns to the father element
|
||||||
|
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
|
||||||
|
|
||||||
|
if ( p == nullptr ) return;
|
||||||
|
|
||||||
|
CBotVar** pp = &p->m_listVar;
|
||||||
|
while ( *pp != nullptr ) pp = &(*pp)->m_next;
|
||||||
|
|
||||||
|
*pp = pVar; // added after
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
|
||||||
|
{
|
||||||
|
CBotCStack* p = this;
|
||||||
|
std::string name = pToken->GetString();
|
||||||
|
|
||||||
|
while (p != nullptr)
|
||||||
|
{
|
||||||
|
CBotVar* pp = p->m_listVar;
|
||||||
|
while ( pp != nullptr)
|
||||||
|
{
|
||||||
|
if (name == pp->GetName())
|
||||||
|
return true;
|
||||||
|
pp = pp->m_next;
|
||||||
|
}
|
||||||
|
if ( p->m_bBlock ) return false;
|
||||||
|
p = p->m_prev;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent)
|
||||||
|
{
|
||||||
|
nIdent = 0;
|
||||||
|
CBotTypResult val(-1);
|
||||||
|
|
||||||
|
val = m_prog->GetExternalCalls()->CompileCall(p, nullptr, ppVars, this);
|
||||||
|
if (val.GetType() < 0)
|
||||||
|
{
|
||||||
|
val = m_prog->GetFunctions()->CompileCall(p->GetString(), ppVars, nIdent);
|
||||||
|
if ( val.GetType() < 0 )
|
||||||
|
{
|
||||||
|
// pVar = nullptr; // the error is not on a particular parameter
|
||||||
|
SetError( static_cast<CBotError>(-val.GetType()), p );
|
||||||
|
val.SetType(-val.GetType());
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
|
{
|
||||||
|
std::string name = pToken->GetString();
|
||||||
|
|
||||||
|
if ( m_prog->GetExternalCalls()->CheckCall(name) ) return true;
|
||||||
|
|
||||||
|
CBotFunction* pp = m_prog->GetFunctions();
|
||||||
|
while ( pp != nullptr )
|
||||||
|
{
|
||||||
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
|
{
|
||||||
|
// are parameters exactly the same?
|
||||||
|
if ( pp->CheckParam( pParam ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pp = pp->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CBotFunction* pp : CBotFunction::m_publicFunctions)
|
||||||
|
{
|
||||||
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
|
{
|
||||||
|
// are parameters exactly the same?
|
||||||
|
if ( pp->CheckParam( pParam ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,269 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotVar/CBotVar.h"
|
||||||
|
#include "CBot/CBotProgram.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotInstr;
|
||||||
|
class CBotDefParam;
|
||||||
|
class CBotToken;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The CBotCStack class Management of the stack of compilation.
|
||||||
|
*/
|
||||||
|
class CBotCStack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CBotCStack
|
||||||
|
* \param ppapa
|
||||||
|
*/
|
||||||
|
CBotCStack(CBotCStack* ppapa);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CBotCStack Destructor.
|
||||||
|
*/
|
||||||
|
~CBotCStack();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief IsOk
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool IsOk();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetError
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotError GetError();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetError Gives error number
|
||||||
|
* \param start
|
||||||
|
* \param end
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotError GetError(int& start, int& end);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetType Set the type of instruction on the stack.
|
||||||
|
* \param type
|
||||||
|
*/
|
||||||
|
void SetType(CBotTypResult& type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetTypResult Gives the type of value on the stack. Type of
|
||||||
|
* instruction on the stack.
|
||||||
|
* \param mode
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult GetTypResult(CBotVar::GetTypeMode mode = CBotVar::GetTypeMode::NORMAL);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetType Gives the type of value on the stack.
|
||||||
|
* \param mode
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
int GetType(CBotVar::GetTypeMode mode = CBotVar::GetTypeMode::NORMAL);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetClass Gives the class of the value on the stack.
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotClass* GetClass();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief AddVar Adds a local variable.
|
||||||
|
* \param p
|
||||||
|
*/
|
||||||
|
void AddVar(CBotVar* p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief FindVar Finds a variable. Seeks a variable on the stack the token
|
||||||
|
* may be a result of TokenTypVar (object of a class) or a pointer in the
|
||||||
|
* source.
|
||||||
|
* \param p
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* FindVar(CBotToken* &p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief FindVar
|
||||||
|
* \param Token
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* FindVar(CBotToken& Token);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CheckVarLocal Test whether a variable is already defined locally.
|
||||||
|
* \param pToken
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool CheckVarLocal(CBotToken* &pToken);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CopyVar Finds and makes a copy.
|
||||||
|
* \param Token
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* CopyVar(CBotToken& Token);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief TokenStack Used only at compile.
|
||||||
|
* \param pToken
|
||||||
|
* \param bBlock
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotCStack* TokenStack(CBotToken* pToken = nullptr, bool bBlock = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return Transmits the result upper.
|
||||||
|
* \param p
|
||||||
|
* \param pParent
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotInstr* Return(CBotInstr* p, CBotCStack* pParent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReturnFunc Transmits the result upper.
|
||||||
|
* \param p
|
||||||
|
* \param pParent
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetVar
|
||||||
|
* \param var
|
||||||
|
*/
|
||||||
|
void SetVar( CBotVar* var );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetCopyVar Puts on the stack a copy of a variable.
|
||||||
|
* \param var
|
||||||
|
*/
|
||||||
|
void SetCopyVar( CBotVar* var );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetVar
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* GetVar();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetStartError
|
||||||
|
* \param pos
|
||||||
|
*/
|
||||||
|
void SetStartError(int pos);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetError
|
||||||
|
* \param n
|
||||||
|
* \param pos
|
||||||
|
*/
|
||||||
|
void SetError(CBotError n, int pos);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetError
|
||||||
|
* \param n
|
||||||
|
* \param p
|
||||||
|
*/
|
||||||
|
void SetError(CBotError n, CBotToken* p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ResetError
|
||||||
|
* \param n
|
||||||
|
* \param start
|
||||||
|
* \param end
|
||||||
|
*/
|
||||||
|
void ResetError(CBotError n, int start, int end);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetRetType
|
||||||
|
* \param type
|
||||||
|
*/
|
||||||
|
void SetRetType(CBotTypResult& type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetRetType
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult GetRetType();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetProgram
|
||||||
|
* \param p
|
||||||
|
*/
|
||||||
|
void SetProgram(CBotProgram* p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetProgram
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotProgram* GetProgram();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CompileCall
|
||||||
|
* \param p
|
||||||
|
* \param ppVars
|
||||||
|
* \param nIdent
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CheckCall Test if a procedure name is already defined somewhere.
|
||||||
|
* \param pToken
|
||||||
|
* \param pParam
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief NextToken
|
||||||
|
* \param p
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool NextToken(CBotToken* &p);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CBotCStack* m_next;
|
||||||
|
CBotCStack* m_prev;
|
||||||
|
|
||||||
|
static CBotError m_error;
|
||||||
|
static int m_end;
|
||||||
|
int m_start;
|
||||||
|
|
||||||
|
//! Result of the operations.
|
||||||
|
CBotVar* m_var;
|
||||||
|
//! Is part of a block (variables are local to this block).
|
||||||
|
bool m_bBlock;
|
||||||
|
CBotVar* m_listVar;
|
||||||
|
//! List of compiled functions.
|
||||||
|
static CBotProgram* m_prog;
|
||||||
|
static CBotTypResult m_retTyp;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotCallMethode.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCallMethode::CBotCallMethode(const std::string& name,
|
||||||
|
bool rExec(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
|
||||||
|
CBotTypResult rCompile(CBotVar* pThis, CBotVar*& pVar))
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
m_rExec = rExec;
|
||||||
|
m_rComp = rCompile;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCallMethode::~CBotCallMethode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotTypResult CBotCallMethode::CompileCall(const std::string& name, CBotVar* pThis, CBotVar** ppVar,
|
||||||
|
CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCallMethode* pt = this;
|
||||||
|
|
||||||
|
while ( pt != nullptr )
|
||||||
|
{
|
||||||
|
if ( pt->m_name == name )
|
||||||
|
{
|
||||||
|
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||||
|
CBotVar* pVar2 = pVar;
|
||||||
|
CBotTypResult r = pt->m_rComp(pThis, pVar2);
|
||||||
|
int ret = r.GetType();
|
||||||
|
if ( ret > 20 )
|
||||||
|
{
|
||||||
|
if (pVar2) pStack->SetError(static_cast<CBotError>(ret), pVar2->GetToken());
|
||||||
|
}
|
||||||
|
delete pVar;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
pt = pt->m_next;
|
||||||
|
}
|
||||||
|
return CBotTypResult(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CBotCallMethode::DoCall(const std::string& name, CBotVar* pThis, CBotVar** ppVars, CBotVar*& pResult,
|
||||||
|
CBotStack* pStack, CBotToken* pToken)
|
||||||
|
{
|
||||||
|
CBotCallMethode* pt = this;
|
||||||
|
|
||||||
|
// search by name
|
||||||
|
|
||||||
|
while ( pt != nullptr )
|
||||||
|
{
|
||||||
|
if ( pt->m_name == name )
|
||||||
|
{
|
||||||
|
// lists the parameters depending on the contents of the stack (pStackVar)
|
||||||
|
|
||||||
|
CBotVar* pVar = MakeListVars(ppVars, true);
|
||||||
|
CBotVar* pVarToDelete = pVar;
|
||||||
|
|
||||||
|
int Exception = 0; // TODO: Change this to CBotError
|
||||||
|
int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetUserPtr());
|
||||||
|
pStack->SetVar(pResult);
|
||||||
|
|
||||||
|
if (res == false)
|
||||||
|
{
|
||||||
|
if (Exception!=0)
|
||||||
|
{
|
||||||
|
// pStack->SetError(Exception, pVar->GetToken());
|
||||||
|
pStack->SetError(static_cast<CBotError>(Exception), pToken);
|
||||||
|
}
|
||||||
|
delete pVarToDelete;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
delete pVarToDelete;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pt = pt->m_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotTypResult.h"
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotVar;
|
||||||
|
class CBotCStack;
|
||||||
|
class CBotStack;
|
||||||
|
class CBotToken;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The CBotCallMethode class Class managing the methods declared by
|
||||||
|
* AddFunction on a class.
|
||||||
|
*/
|
||||||
|
class CBotCallMethode : public CBotLinkedList<CBotCallMethode>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CBotCallMethode
|
||||||
|
* \param name
|
||||||
|
* \param rExec
|
||||||
|
* \param rCompile
|
||||||
|
*/
|
||||||
|
CBotCallMethode(const std::string& name,
|
||||||
|
bool rExec(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
|
||||||
|
CBotTypResult rCompile(CBotVar* pThis, CBotVar*& pVar));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ~CBotCallMethode
|
||||||
|
*/
|
||||||
|
~CBotCallMethode();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CompileCall Is acceptable by a call procedure name and given
|
||||||
|
* parameters.
|
||||||
|
* \param name
|
||||||
|
* \param pThis
|
||||||
|
* \param ppVars
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult CompileCall(const std::string& name, CBotVar* pThis, CBotVar** ppVars,
|
||||||
|
CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief DoCall
|
||||||
|
* \param name
|
||||||
|
* \param pThis
|
||||||
|
* \param ppVars
|
||||||
|
* \param pResult
|
||||||
|
* \param pStack
|
||||||
|
* \param pFunc
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
int DoCall(const std::string& name, CBotVar* pThis, CBotVar** ppVars, CBotVar*& pResult,
|
||||||
|
CBotStack* pStack, CBotToken* pFunc);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_name;
|
||||||
|
bool (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user);
|
||||||
|
CBotTypResult (*m_rComp) (CBotVar* pThis, CBotVar* &pVar);
|
||||||
|
friend class CBotClass;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,394 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefines.h"
|
||||||
|
#include "CBot/CBotTypResult.h"
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <deque>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotCallMethode;
|
||||||
|
class CBotFunction;
|
||||||
|
class CBotProgram;
|
||||||
|
class CBotStack;
|
||||||
|
class CBotDefParam;
|
||||||
|
class CBotToken;
|
||||||
|
class CBotCStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A CBot class definition
|
||||||
|
*
|
||||||
|
* \section Examples Usage examples
|
||||||
|
*
|
||||||
|
* Define class "point":
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* CBotClass* classPoint = new CBotClass("CPoint", nullptr);
|
||||||
|
* classPoint->AddItem("x", CBotTypResult(CBotTypFloat)); // add ".x"
|
||||||
|
* classPoint->AddItem("y", CBotTypResult(CBotTypFloat)); // add ".y"
|
||||||
|
*
|
||||||
|
* // This class can be used in CBot like so:
|
||||||
|
* // point position;
|
||||||
|
* // position.x = 12;
|
||||||
|
* // position.y = -13.6
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Define readonly class "object" with members of type "point" and some methods:
|
||||||
|
* \code
|
||||||
|
* CBotClass* classObject = new CBotClass("object", nullptr);
|
||||||
|
* classObject->AddItem("category", CBotTypResult(CBotTypInt), CBotVar::ProtectionType::ReadOnly);
|
||||||
|
* classObject->AddItem("position", CBotTypResult(CBotTypClass, classPoint), CBotVar::ProtectionType::ReadOnly);
|
||||||
|
* classObject->AddFunction("func", rFunc, cFunc); // TODO: Document function format for class methods (different from standard CBotProgram::AddFunction()!)
|
||||||
|
*
|
||||||
|
* // This class can be used in CBot like so:
|
||||||
|
* // object item = radar(Me);
|
||||||
|
* // goto(item.position);
|
||||||
|
* // item.func();
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Define class "robot" derrived from "object":
|
||||||
|
* \code
|
||||||
|
* CBotClass* classRobot = new CBotClass("object", classObject);
|
||||||
|
* classRobot->AddItem("velocity", CBotTypResult(CBotTypClass, classPoint), CBotVar::ProtectionType::ReadOnly);
|
||||||
|
* classRobot->AddFunction("func2", rFunc2, cFunc2);
|
||||||
|
*
|
||||||
|
* // This class can be used in CBot like so:
|
||||||
|
* // robot item = something();
|
||||||
|
* // goto(item.position); // can still access base class
|
||||||
|
* // item.func(); // can still call base class
|
||||||
|
* // item.func2(); // but also the derrived class
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Create instance of the "robot" class:
|
||||||
|
* \code
|
||||||
|
* CBotVar* var = new CBotVar("variableName", classRobot);
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Access members of the "point" class:
|
||||||
|
* \code
|
||||||
|
* CBotVar* varX = classInstance->GetItem("x");
|
||||||
|
* float x = varX->GetValFloat();
|
||||||
|
* CBotVar* varY = classInstance->GetItem("y");
|
||||||
|
* float y = varX->GetValFloat();
|
||||||
|
*
|
||||||
|
* // OR
|
||||||
|
*
|
||||||
|
* CBotVar* var = classInstance->GetItemList();
|
||||||
|
* float x = var->GetValFloat();
|
||||||
|
* var->GetNext();
|
||||||
|
* float y = var->GetValFloat();
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
class CBotClass : public CBotLinkedList<CBotClass>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief CBotClass Constructor. Once a class is created, it is known around
|
||||||
|
* CBot intrinsic mode gives a class that is not managed by pointers.
|
||||||
|
* \param name
|
||||||
|
* \param parent
|
||||||
|
* \param bIntrinsic
|
||||||
|
*/
|
||||||
|
CBotClass(const std::string& name,
|
||||||
|
CBotClass* parent,
|
||||||
|
bool bIntrinsic = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CBotClass Destructor.
|
||||||
|
*/
|
||||||
|
~CBotClass( );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create
|
||||||
|
* \param name
|
||||||
|
* \param parent
|
||||||
|
* \param intrinsic
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotClass* Create(const std::string& name,
|
||||||
|
CBotClass* parent,
|
||||||
|
bool intrinsic = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief AddFunction This call allows to add as external new method
|
||||||
|
* used by the objects of this class. See (**) at end of this file for
|
||||||
|
* more details.
|
||||||
|
* \param name
|
||||||
|
* \param rExec
|
||||||
|
* \param rCompile
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool AddFunction(const std::string& name,
|
||||||
|
bool rExec(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
|
||||||
|
CBotTypResult rCompile(CBotVar* pThis, CBotVar*& pVar));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SetUpdateFunc Defines routine to be called to update the elements
|
||||||
|
* of the class.
|
||||||
|
* \param rUpdate
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool SetUpdateFunc(void rUpdate(CBotVar* thisVar, void* user));
|
||||||
|
//
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief AddItem Adds an element to the class.
|
||||||
|
* \param name
|
||||||
|
* \param type
|
||||||
|
* \param mPrivate
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool AddItem(std::string name, CBotTypResult type,
|
||||||
|
CBotVar::ProtectionLevel mPrivate = CBotVar::ProtectionLevel::Public);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief AddItem Adds an item by passing the pointer to an instance of a
|
||||||
|
* variable the object is taken as is, so do not destroyed.
|
||||||
|
* \param pVar
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool AddItem(CBotVar* pVar);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetName Gives the name of the class.
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
std::string GetName();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetParent Gives the parent class (or nullptr).
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotClass* GetParent();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief IsChildOf True if a class is derived (Extends) of another.
|
||||||
|
* \param pClass
|
||||||
|
* \return true also if the classes are identical
|
||||||
|
*/
|
||||||
|
bool IsChildOf(CBotClass* pClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find Trouve une classe d'après son nom
|
||||||
|
* \param pToken
|
||||||
|
* \return A class by it's its name.
|
||||||
|
*/
|
||||||
|
static CBotClass* Find(CBotToken* &pToken);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find
|
||||||
|
* \param name
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotClass* Find(const std::string& name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetVar Return the list of variables.
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* GetVar();
|
||||||
|
/*!
|
||||||
|
* \brief GetItem One of the variables according to its name.
|
||||||
|
* \param name
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* GetItem(const std::string& name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetItemRef
|
||||||
|
* \param nIdent
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotVar* GetItemRef(int nIdent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CompileMethode Compiles a method associated with an instance of
|
||||||
|
* class the method can be declared by the user or AddFunction.
|
||||||
|
* \param name
|
||||||
|
* \param pThis
|
||||||
|
* \param ppParams
|
||||||
|
* \param pStack
|
||||||
|
* \param nIdent
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult CompileMethode(const std::string& name,
|
||||||
|
CBotVar* pThis,
|
||||||
|
CBotVar** ppParams,
|
||||||
|
CBotCStack* pStack,
|
||||||
|
long& nIdent);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ExecuteMethode Executes a method.
|
||||||
|
* \param nIdent
|
||||||
|
* \param name
|
||||||
|
* \param pThis
|
||||||
|
* \param ppParams
|
||||||
|
* \param pResult
|
||||||
|
* \param pStack
|
||||||
|
* \param pToken
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ExecuteMethode(long& nIdent,
|
||||||
|
const std::string& name,
|
||||||
|
CBotVar* pThis,
|
||||||
|
CBotVar** ppParams,
|
||||||
|
CBotVar*& pResult,
|
||||||
|
CBotStack*& pStack,
|
||||||
|
CBotToken* pToken);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreMethode Restored the execution stack.
|
||||||
|
* \param nIdent
|
||||||
|
* \param name
|
||||||
|
* \param pThis
|
||||||
|
* \param ppParams
|
||||||
|
* \param pStack
|
||||||
|
*/
|
||||||
|
void RestoreMethode(long& nIdent,
|
||||||
|
const std::string& name,
|
||||||
|
CBotVar* pThis,
|
||||||
|
CBotVar** ppParams,
|
||||||
|
CBotStack*& pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile Compiles a class declared by the user.
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotClass* Compile(CBotToken* &p,
|
||||||
|
CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile1
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotClass* Compile1(CBotToken* &p,
|
||||||
|
CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CompileDefItem
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param bSecond
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool CompileDefItem(CBotToken* &p,
|
||||||
|
CBotCStack* pStack,
|
||||||
|
bool bSecond);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief IsIntrinsic
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool IsIntrinsic();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Purge
|
||||||
|
*/
|
||||||
|
void Purge();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Free
|
||||||
|
*/
|
||||||
|
static void ClearPublic();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief SaveStaticState
|
||||||
|
* \param pf
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static bool SaveStaticState(FILE* pf);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreStaticState
|
||||||
|
* \param pf
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static bool RestoreStaticState(FILE* pf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Request a lock on this class (for "synchronized" keyword)
|
||||||
|
* \param prog Program that requests the lock
|
||||||
|
* \return true if lock was acquired, false if the lock is already taken
|
||||||
|
*/
|
||||||
|
bool Lock(CBotProgram* prog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Release the lock acquired in Lock()
|
||||||
|
* If you call Lock() multiple times for the same program, you have to call Unlock() multiple times too
|
||||||
|
*/
|
||||||
|
void Unlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Release all locks in all classes held by this program
|
||||||
|
* \param prog Program to release the locks from
|
||||||
|
*/
|
||||||
|
static void FreeLock(CBotProgram* prog);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CheckCall Test if a procedure name is already defined somewhere.
|
||||||
|
* \param program
|
||||||
|
* \param pToken
|
||||||
|
* \param pParam
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool CheckCall(CBotProgram* program, CBotDefParam* pParam, CBotToken*& pToken);
|
||||||
|
|
||||||
|
void Update(CBotVar* var, void* user);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! List of all public classes
|
||||||
|
static std::set<CBotClass*> m_publicClasses;
|
||||||
|
|
||||||
|
|
||||||
|
//! true if this class is fully compiled, false if only precompiled
|
||||||
|
bool m_IsDef;
|
||||||
|
//! Name of this class
|
||||||
|
std::string m_name;
|
||||||
|
//! Parent class
|
||||||
|
CBotClass* m_parent;
|
||||||
|
//! Number of variables in the chain
|
||||||
|
int m_nbVar;
|
||||||
|
//! Intrinsic class
|
||||||
|
bool m_bIntrinsic;
|
||||||
|
//! Linked list of all class fields
|
||||||
|
CBotVar* m_pVar;
|
||||||
|
//! Linked list of all class external calls
|
||||||
|
CBotCallMethode* m_pCalls;
|
||||||
|
//! Linked list of all class methods
|
||||||
|
CBotFunction* m_pMethod;
|
||||||
|
void (*m_rUpdate)(CBotVar* thisVar, void* user);
|
||||||
|
|
||||||
|
//! How many times the program currently holding the lock called Lock()
|
||||||
|
int m_lockCurrentCount = 0;
|
||||||
|
//! Programs waiting for lock. m_lockProg[0] is the program currently holding the lock, if any
|
||||||
|
std::deque<CBotProgram*> m_lockProg{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
|
||||||
* Copyright (C) 2001-2015, 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
|
||||||
// expression of type Opérande1 > Opérande2
|
|
||||||
// Opérande1 != Opérande2
|
|
||||||
// etc.
|
|
||||||
|
|
||||||
#include "CBot.h"
|
|
||||||
|
|
||||||
// various constructeurs
|
|
||||||
|
|
||||||
CBotCompExpr::CBotCompExpr()
|
|
||||||
{
|
|
||||||
m_leftop =
|
|
||||||
m_rightop = nullptr;
|
|
||||||
name = "CBotCompExpr";
|
|
||||||
}
|
|
||||||
|
|
||||||
CBotCompExpr::~CBotCompExpr()
|
|
||||||
{
|
|
||||||
delete m_leftop;
|
|
||||||
delete m_rightop;
|
|
||||||
}
|
|
||||||
|
|
||||||
fichier plus utilise;
|
|
||||||
|
|
||||||
// compile instruction of type A < B
|
|
||||||
|
|
||||||
CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|
||||||
{
|
|
||||||
CBotCStack* pStk = pStack->AddStack();
|
|
||||||
|
|
||||||
CBotInstr* left = CBotAddExpr::Compile( p, pStk ); // expression A + B left
|
|
||||||
if (left == nullptr) return pStack->Return(nullptr, pStk); // error
|
|
||||||
|
|
||||||
if ( p->GetType() == ID_HI ||
|
|
||||||
p->GetType() == ID_LO ||
|
|
||||||
p->GetType() == ID_HS ||
|
|
||||||
p->GetType() == ID_LS ||
|
|
||||||
p->GetType() == ID_EQ ||
|
|
||||||
p->GetType() == ID_NE) // the various comparisons
|
|
||||||
{
|
|
||||||
CBotCompExpr* inst = new CBotCompExpr(); // element for operation
|
|
||||||
inst->SetToken(p); // stores the operation
|
|
||||||
|
|
||||||
int type1, type2;
|
|
||||||
type1 = pStack->GetType();
|
|
||||||
|
|
||||||
p = p->Next();
|
|
||||||
if ( nullptr != (inst->m_rightop = CBotAddExpr::Compile( p, pStk )) ) // expression A + B right
|
|
||||||
{
|
|
||||||
type2 = pStack->GetType();
|
|
||||||
// are the results compatible
|
|
||||||
if ( type1 == type2 )
|
|
||||||
{
|
|
||||||
inst->m_leftop = left;
|
|
||||||
pStk->SetVar(new CBotVar(nullptr, CBotTypBoolean));
|
|
||||||
// the result is a boolean
|
|
||||||
return pStack->Return(inst, pStk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete left;
|
|
||||||
delete inst;
|
|
||||||
return pStack->Return(nullptr, pStk);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pStack->Return(left, pStk);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// perform the operation
|
|
||||||
|
|
||||||
bool CBotCompExpr::Execute(CBotStack* &pStack)
|
|
||||||
{
|
|
||||||
CBotStack* pStk1 = pStack->AddStack(this);
|
|
||||||
// if ( pStk1 == EOX ) return TRUE;
|
|
||||||
|
|
||||||
if ( pStk1->GetState() == 0 && !m_leftop->Execute(pStk1) ) return FALSE; // interrupted here ?
|
|
||||||
|
|
||||||
pStk1->SetState(1); // finished
|
|
||||||
|
|
||||||
// requires a little more stack to not touch the result of the left
|
|
||||||
CBotStack* pStk2 = pStk1->AddStack();
|
|
||||||
|
|
||||||
if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrupted here ?
|
|
||||||
|
|
||||||
int type1 = pStk1->GetType();
|
|
||||||
int type2 = pStk2->GetType();
|
|
||||||
|
|
||||||
CBotVar* result = new CBotVar( nullptr, CBotTypBoolean );
|
|
||||||
|
|
||||||
switch (GetTokenType())
|
|
||||||
{
|
|
||||||
case ID_LO:
|
|
||||||
result->Lo(pStk1->GetVar(), pStk2->GetVar()); // lower
|
|
||||||
break;
|
|
||||||
case ID_HI:
|
|
||||||
result->Hi(pStk1->GetVar(), pStk2->GetVar()); // higher
|
|
||||||
break;
|
|
||||||
case ID_LS:
|
|
||||||
result->Ls(pStk1->GetVar(), pStk2->GetVar()); // lower or equal
|
|
||||||
break;
|
|
||||||
case ID_HS:
|
|
||||||
result->Hs(pStk1->GetVar(), pStk2->GetVar()); // higher of equal
|
|
||||||
break;
|
|
||||||
case ID_EQ:
|
|
||||||
result->Eq(pStk1->GetVar(), pStk2->GetVar()); // equal
|
|
||||||
break;
|
|
||||||
case ID_NE:
|
|
||||||
result->Ne(pStk1->GetVar(), pStk2->GetVar()); // not equal
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pStk2->SetVar(result); // puts the result on the stack
|
|
||||||
|
|
||||||
pStk1->Return(pStk2); // frees the stack
|
|
||||||
return pStack->Return(pStk1); // transmit the result
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDebug.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotProgram.h"
|
||||||
|
#include "CBot/CBotInstr/CBotFunction.h"
|
||||||
|
#include "CBot/CBotInstr/CBotInstrCall.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
void CBotDebug::DumpCompiledProgram(CBotProgram* program)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "digraph {" << std::endl;
|
||||||
|
|
||||||
|
CBotFunction* func = program->GetFunctions();
|
||||||
|
std::map<long, CBotFunction*> funcIdMap;
|
||||||
|
while (func != nullptr)
|
||||||
|
{
|
||||||
|
funcIdMap[func->m_nFuncIdent] = func;
|
||||||
|
func = func->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<CBotInstr*> finished;
|
||||||
|
std::map<void*, int> instructions;
|
||||||
|
int instructionsNextId = 0;
|
||||||
|
auto GetPointerAsString = [&instructions, &instructionsNextId](void* ptr) -> std::string
|
||||||
|
{
|
||||||
|
if(instructions.count(ptr) == 0)
|
||||||
|
{
|
||||||
|
instructions[ptr] = instructionsNextId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[20];
|
||||||
|
sprintf(buffer, "instr%d", instructions[ptr]);
|
||||||
|
return std::string(buffer);
|
||||||
|
};
|
||||||
|
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
|
||||||
|
{
|
||||||
|
if (finished.find(instr) != finished.end()) return;
|
||||||
|
finished.insert(instr);
|
||||||
|
|
||||||
|
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
|
||||||
|
std::string data = instr->GetDebugData();
|
||||||
|
boost::algorithm::replace_all(data, "&", "&");
|
||||||
|
boost::algorithm::replace_all(data, "<", "<");
|
||||||
|
boost::algorithm::replace_all(data, ">", ">");
|
||||||
|
label += data;
|
||||||
|
boost::algorithm::replace_all(label, "\n", "<br/>");
|
||||||
|
|
||||||
|
std::string additional = "";
|
||||||
|
if (instr->GetDebugName() == "CBotFunction")
|
||||||
|
{
|
||||||
|
label = instr->GetDebugData(); // hide the title
|
||||||
|
CBotFunction* function = static_cast<CBotFunction*>(instr);
|
||||||
|
if (function == program->m_entryPoint) additional += " shape=box3d";
|
||||||
|
else additional += " shape=box";
|
||||||
|
if (function->IsExtern()) additional += " color=cyan";
|
||||||
|
else additional += " color=blue";
|
||||||
|
additional += " group=func";
|
||||||
|
}
|
||||||
|
|
||||||
|
ss << GetPointerAsString(instr) << " [label=<" << label << ">" << additional << "]" << std::endl;
|
||||||
|
|
||||||
|
if (instr->GetDebugName() == "CBotInstrCall")
|
||||||
|
{
|
||||||
|
CBotInstrCall* call = static_cast<CBotInstrCall*>(instr);
|
||||||
|
if (funcIdMap.count(call->m_nFuncIdent) > 0)
|
||||||
|
{
|
||||||
|
ss << GetPointerAsString(instr) << " -> " << GetPointerAsString(funcIdMap[call->m_nFuncIdent]) << " [style=dotted color=gray weight=15]" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& it : instr->GetDebugLinks())
|
||||||
|
{
|
||||||
|
if (it.second == nullptr) continue;
|
||||||
|
if (it.second->GetDebugName() == "CBotFunction") continue;
|
||||||
|
DumpInstr(it.second);
|
||||||
|
ss << GetPointerAsString(instr) << " -> " << GetPointerAsString(it.second) << " [label=\"" << it.first << "\"" << (it.first == "m_next" ? " weight=1" : " weight=5") << "]" << std::endl;
|
||||||
|
if (it.first == "m_next" || (instr->GetDebugName() == "CBotFunction" && it.first == "m_block") || (instr->GetDebugName() == "CBotListInstr" && it.first == "m_instr"))
|
||||||
|
{
|
||||||
|
ss << "{ rank=same; " << GetPointerAsString(instr) << "; " << GetPointerAsString(it.second) << "; }" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (program->m_entryPoint != nullptr)
|
||||||
|
{
|
||||||
|
DumpInstr(program->m_entryPoint);
|
||||||
|
}
|
||||||
|
func = program->GetFunctions();
|
||||||
|
std::string prev = GetPointerAsString(program->m_entryPoint);
|
||||||
|
while (func != nullptr)
|
||||||
|
{
|
||||||
|
if (func != program->m_entryPoint)
|
||||||
|
{
|
||||||
|
DumpInstr(func);
|
||||||
|
|
||||||
|
//ss << prev << " -> " << GetPointerAsString(func) << " [style=invis]" << std::endl;
|
||||||
|
prev = GetPointerAsString(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
func = func->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
ss << "}" << std::endl;
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
|
||||||
|
/* // Terrible platform-dependent code :P
|
||||||
|
std::stringstream filename;
|
||||||
|
filename << "compiled" << (program->m_entryPoint != nullptr ? "_"+program->m_entryPoint->GetName() : "") << ".png";
|
||||||
|
|
||||||
|
int pipeOut[2];
|
||||||
|
pipe(pipeOut);
|
||||||
|
if (fork())
|
||||||
|
{
|
||||||
|
close(pipeOut[0]);
|
||||||
|
write(pipeOut[1], ss.str().c_str(), ss.str().size());
|
||||||
|
close(pipeOut[1]);
|
||||||
|
int rv;
|
||||||
|
wait(&rv);
|
||||||
|
if(rv != 0) exit(rv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dup2(pipeOut[0], 0);
|
||||||
|
close(pipeOut[1]);
|
||||||
|
execl("/usr/bin/dot", "dot", "-Tpng", "-o", filename.str().c_str(), nullptr);
|
||||||
|
exit(1); // failed to start
|
||||||
|
} */
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
class CBotProgram;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Various utilities used for debugging
|
||||||
|
*/
|
||||||
|
class CBotDebug
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* \brief Dump the compiled class structure of the given program to stdout as DOT graph
|
||||||
|
* \param program Program to dump
|
||||||
|
*/
|
||||||
|
static void DumpCompiledProgram(CBotProgram* program);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefParam.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVarClass.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefParam::CBotDefParam()
|
||||||
|
{
|
||||||
|
m_nIdent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefParam::~CBotDefParam()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
// mainly not pStack->TokenStack here
|
||||||
|
// declared variables must remain visible thereafter
|
||||||
|
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPENPAR))
|
||||||
|
{
|
||||||
|
CBotDefParam* list = nullptr;
|
||||||
|
|
||||||
|
while (!IsOfType(p, ID_CLOSEPAR))
|
||||||
|
{
|
||||||
|
CBotDefParam* param = new CBotDefParam();
|
||||||
|
if (list == nullptr) list = param;
|
||||||
|
else list->AddNext(param); // added to the list
|
||||||
|
|
||||||
|
// CBotClass* pClass = nullptr;//= CBotClass::Find(p);
|
||||||
|
param->m_typename = p->GetString();
|
||||||
|
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
||||||
|
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
|
||||||
|
|
||||||
|
if (param->m_type.GetType() > 0)
|
||||||
|
{
|
||||||
|
CBotToken* pp = p;
|
||||||
|
param->m_token = *p;
|
||||||
|
if (pStack->IsOk() && IsOfType(p, TokenTypVar) )
|
||||||
|
{
|
||||||
|
|
||||||
|
// variable already declared?
|
||||||
|
if (pStack->CheckVarLocal(pp))
|
||||||
|
{
|
||||||
|
pStack->SetError(CBotErrRedefVar, pp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
|
||||||
|
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
|
||||||
|
// if ( pClass ) var->SetClass(pClass);
|
||||||
|
var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized
|
||||||
|
param->m_nIdent = CBotVar::NextUniqNum();
|
||||||
|
var->SetUniqNum(param->m_nIdent);
|
||||||
|
pStack->AddVar(var); // place on the stack
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_COMMA) || p->GetType() == ID_CLOSEPAR)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrClosePar, p->GetStart());
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrNoType, p);
|
||||||
|
delete list;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrOpenPar, p->GetStart());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
CBotDefParam* p = this;
|
||||||
|
|
||||||
|
while ( p != nullptr )
|
||||||
|
{
|
||||||
|
// creates a local variable on the stack
|
||||||
|
CBotVar* newvar = CBotVar::Create(p->m_token.GetString(), p->m_type);
|
||||||
|
|
||||||
|
// serves to make the transformation of types:
|
||||||
|
if ( ppVars != nullptr && ppVars[i] != nullptr )
|
||||||
|
{
|
||||||
|
switch (p->m_type.GetType())
|
||||||
|
{
|
||||||
|
case CBotTypInt:
|
||||||
|
newvar->SetValInt(ppVars[i]->GetValInt());
|
||||||
|
break;
|
||||||
|
case CBotTypFloat:
|
||||||
|
newvar->SetValFloat(ppVars[i]->GetValFloat());
|
||||||
|
break;
|
||||||
|
case CBotTypString:
|
||||||
|
newvar->SetValString(ppVars[i]->GetValString());
|
||||||
|
break;
|
||||||
|
case CBotTypBoolean:
|
||||||
|
newvar->SetValInt(ppVars[i]->GetValInt());
|
||||||
|
break;
|
||||||
|
case CBotTypIntrinsic:
|
||||||
|
(static_cast<CBotVarClass*>(newvar))->Copy(ppVars[i], false);
|
||||||
|
break;
|
||||||
|
case CBotTypPointer:
|
||||||
|
case CBotTypArrayPointer:
|
||||||
|
{
|
||||||
|
newvar->SetPointer(ppVars[i]->GetPointer());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newvar->SetUniqNum(p->m_nIdent);
|
||||||
|
pj->AddVar(newvar); // add a variable
|
||||||
|
p = p->m_next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
// int i = 0;
|
||||||
|
CBotDefParam* p = this;
|
||||||
|
|
||||||
|
while ( p != nullptr )
|
||||||
|
{
|
||||||
|
// creates a local variable on the stack
|
||||||
|
CBotVar* var = pj->FindVar(p->m_token.GetString());
|
||||||
|
var->SetUniqNum(p->m_nIdent);
|
||||||
|
p = p->m_next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CBotDefParam::GetType()
|
||||||
|
{
|
||||||
|
return m_type.GetType();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotTypResult CBotDefParam::GetTypResult()
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string CBotDefParam::GetParamString()
|
||||||
|
{
|
||||||
|
std::string param;
|
||||||
|
|
||||||
|
param = m_typename;
|
||||||
|
param += ' ';
|
||||||
|
|
||||||
|
param += m_token.GetString();
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotToken.h"
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotCStack;
|
||||||
|
class CBotStack;
|
||||||
|
class CBotVar;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The CBotDefParam class A list of parameters.
|
||||||
|
*/
|
||||||
|
class CBotDefParam : public CBotLinkedList<CBotDefParam>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CBotDefParam
|
||||||
|
*/
|
||||||
|
CBotDefParam();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ~CBotDefParam
|
||||||
|
*/
|
||||||
|
~CBotDefParam();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile Compiles a list of parameters.
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotDefParam* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute
|
||||||
|
* \param ppVars
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotVar** ppVars, CBotStack* &pj);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetType
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
int GetType();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetTypResult
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
CBotTypResult GetTypResult();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GetParamString
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
std::string GetParamString();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Name of the parameter.
|
||||||
|
CBotToken m_token;
|
||||||
|
//! Type name.
|
||||||
|
std::string m_typename;
|
||||||
|
//! Type of paramteter.
|
||||||
|
CBotTypResult m_type;
|
||||||
|
long m_nIdent;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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
|
||||||
|
|
||||||
|
#define STACKMEM 1 /// \def preserve memory for the execution stack
|
||||||
|
#define MAXSTACK 990 /// \def stack size reserved
|
||||||
|
|
||||||
|
#define MAXARRAYSIZE 9999
|
||||||
|
|
||||||
|
//! Define the current CBot version
|
||||||
|
#define CBOTVERSION 104
|
||||||
|
|
||||||
|
// for SetUserPtr when deleting an object
|
||||||
|
// \TODO define own types to distinct between different states of objects
|
||||||
|
#define OBJECTDELETED (reinterpret_cast<void*>(-1))
|
||||||
|
// value set before initialization
|
||||||
|
#define OBJECTCREATED (reinterpret_cast<void*>(-2))
|
1123
src/CBot/CBotDll.h
1123
src/CBot/CBotDll.h
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,260 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file CBotEnums.h
|
||||||
|
* \brief Some enum values used across the CBot engine
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Defines known types. This types are modeled on Java types.
|
||||||
|
*
|
||||||
|
* Do not change the order of elements.
|
||||||
|
*/
|
||||||
|
enum CBotType
|
||||||
|
{
|
||||||
|
CBotTypVoid = 0, //!< void
|
||||||
|
CBotTypByte = 1, //!< byte (NOT IMPLEMENTED)
|
||||||
|
CBotTypShort = 2, //!< short (NOT IMPLEMENTED)
|
||||||
|
CBotTypChar = 3, //!< char (NOT IMPLEMENTED)
|
||||||
|
CBotTypInt = 4, //!< int
|
||||||
|
CBotTypLong = 5, //!< long (NOT IMPLEMENTED)
|
||||||
|
CBotTypFloat = 6, //!< float
|
||||||
|
CBotTypDouble = 7, //!< double (NOT IMPLEMENTED)
|
||||||
|
CBotTypBoolean = 8, //!< bool
|
||||||
|
CBotTypString = 9, //!< string
|
||||||
|
|
||||||
|
CBotTypArrayPointer = 10, //!< Pointer to an array (::CBotTypArrayBody)
|
||||||
|
CBotTypArrayBody = 11, //!< Array
|
||||||
|
|
||||||
|
CBotTypPointer = 12, //!< Pointer to a class (::CBotTypClass or ::CBotTypIntrinsic)
|
||||||
|
CBotTypNullPointer = 13, //!< Null pointer
|
||||||
|
CBotTypClass = 15, //!< Class instance
|
||||||
|
CBotTypIntrinsic = 16, //!< Intrinsic class instance
|
||||||
|
|
||||||
|
CBotTypMAX = 20
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Different modes for CBotProgram::GetPosition
|
||||||
|
*/
|
||||||
|
enum CBotGet
|
||||||
|
{
|
||||||
|
GetPosExtern = 1,
|
||||||
|
GetPosNom = 2,
|
||||||
|
GetPosParam = 3,
|
||||||
|
GetPosBloc = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief This enum contains possible token types
|
||||||
|
*/
|
||||||
|
enum TokenId
|
||||||
|
{
|
||||||
|
TokenKeyWord = 2000, //!< keywords
|
||||||
|
ID_IF = 2000,
|
||||||
|
ID_ELSE,
|
||||||
|
ID_WHILE,
|
||||||
|
ID_DO,
|
||||||
|
ID_FOR,
|
||||||
|
ID_BREAK,
|
||||||
|
ID_CONTINUE,
|
||||||
|
ID_SWITCH,
|
||||||
|
ID_CASE,
|
||||||
|
ID_DEFAULT,
|
||||||
|
ID_TRY,
|
||||||
|
ID_THROW,
|
||||||
|
ID_CATCH,
|
||||||
|
ID_FINALLY,
|
||||||
|
ID_TXT_AND,
|
||||||
|
ID_TXT_OR,
|
||||||
|
ID_TXT_NOT,
|
||||||
|
ID_RETURN,
|
||||||
|
ID_CLASS,
|
||||||
|
ID_EXTENDS,
|
||||||
|
ID_SYNCHO,
|
||||||
|
ID_NEW,
|
||||||
|
ID_PUBLIC,
|
||||||
|
ID_EXTERN,
|
||||||
|
ID_STATIC,
|
||||||
|
ID_PROTECTED,
|
||||||
|
ID_PRIVATE,
|
||||||
|
ID_INT,
|
||||||
|
ID_FLOAT,
|
||||||
|
ID_BOOLEAN,
|
||||||
|
ID_STRING,
|
||||||
|
ID_VOID,
|
||||||
|
ID_BOOL,
|
||||||
|
|
||||||
|
TokenKeyVal = 2200, //!< keywords that represent values (true, false, null, nan)
|
||||||
|
ID_TRUE = 2200,
|
||||||
|
ID_FALSE,
|
||||||
|
ID_NULL,
|
||||||
|
ID_NAN,
|
||||||
|
|
||||||
|
TokenKeyOp = 2300, //!< operators
|
||||||
|
ID_OPENPAR = 2300,
|
||||||
|
ID_CLOSEPAR,
|
||||||
|
ID_OPBLK,
|
||||||
|
ID_CLBLK,
|
||||||
|
ID_SEP,
|
||||||
|
ID_COMMA,
|
||||||
|
ID_DOTS,
|
||||||
|
ID_DOT,
|
||||||
|
ID_OPBRK,
|
||||||
|
ID_CLBRK,
|
||||||
|
ID_DBLDOTS,
|
||||||
|
ID_LOGIC,
|
||||||
|
ID_ADD,
|
||||||
|
ID_SUB,
|
||||||
|
ID_MUL,
|
||||||
|
ID_DIV,
|
||||||
|
ID_ASS,
|
||||||
|
ID_ASSADD,
|
||||||
|
ID_ASSSUB,
|
||||||
|
ID_ASSMUL,
|
||||||
|
ID_ASSDIV,
|
||||||
|
ID_ASSOR,
|
||||||
|
ID_ASSAND,
|
||||||
|
ID_ASSXOR,
|
||||||
|
ID_ASSSL,
|
||||||
|
ID_ASSSR,
|
||||||
|
ID_ASSASR,
|
||||||
|
ID_SL,
|
||||||
|
ID_SR,
|
||||||
|
ID_ASR,
|
||||||
|
ID_INC,
|
||||||
|
ID_DEC,
|
||||||
|
ID_LO,
|
||||||
|
ID_HI,
|
||||||
|
ID_LS,
|
||||||
|
ID_HS,
|
||||||
|
ID_EQ,
|
||||||
|
ID_NE,
|
||||||
|
ID_AND,
|
||||||
|
ID_XOR,
|
||||||
|
ID_OR,
|
||||||
|
ID_LOG_AND,
|
||||||
|
ID_LOG_OR,
|
||||||
|
ID_LOG_NOT,
|
||||||
|
ID_NOT,
|
||||||
|
ID_MODULO,
|
||||||
|
ID_POWER,
|
||||||
|
ID_ASSMODULO,
|
||||||
|
|
||||||
|
TX_UNDEF = 4000,
|
||||||
|
TX_NAN
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Types of tokens
|
||||||
|
*/
|
||||||
|
enum TokenType
|
||||||
|
{
|
||||||
|
TokenTypNone = 0,
|
||||||
|
TokenTypKeyWord = 1, //!< keyword of the language (see TokenKeyWord)
|
||||||
|
TokenTypNum = 2, //!< number
|
||||||
|
TokenTypString = 3, //!< string
|
||||||
|
TokenTypVar = 4, //!< a variable name
|
||||||
|
TokenTypDef = 5 //!< value according DefineNum
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief This enum contains possible CBot error values. Values in range 5000-5999 are compile errors, 6000-6999 are runtime errors
|
||||||
|
*
|
||||||
|
* Note that other values may be returned, for example exceptions for user-defined builtin functions, or "throw" instruction
|
||||||
|
*
|
||||||
|
* Also note that these can't overlap with CBotType, see CBotTypResult for explanation
|
||||||
|
*/
|
||||||
|
enum CBotError : int
|
||||||
|
{
|
||||||
|
CBotNoErr = 0,
|
||||||
|
|
||||||
|
// Compile errors
|
||||||
|
CBotErrOpenPar = 5000, //!< missing the opening parenthesis
|
||||||
|
CBotErrClosePar = 5001, //!< missing the closing parenthesis
|
||||||
|
CBotErrNotBoolean = 5002, //!< expression must be a boolean
|
||||||
|
CBotErrUndefVar = 5003, //!< undeclared variable
|
||||||
|
CBotErrBadLeft = 5004, //!< assignment impossible ( 5 = ... )
|
||||||
|
CBotErrNoTerminator = 5005, //!< semicolon expected
|
||||||
|
CBotErrCaseOut = 5006, //!< case outside a switch
|
||||||
|
CBotErrNoEnd = 5007, //!< instructions after final closing brace
|
||||||
|
CBotErrCloseBlock = 5008, //!< missing " } "
|
||||||
|
CBotErrElseWhitoutIf = 5009, //!< else without matching if
|
||||||
|
CBotErrOpenBlock = 5010, //!< missing " { "
|
||||||
|
CBotErrBadType1 = 5011, //!< wrong type for the assignment
|
||||||
|
CBotErrRedefVar = 5012, //!< redefinition of the variable
|
||||||
|
CBotErrBadType2 = 5013, //!< Two operands are incompatible
|
||||||
|
CBotErrUndefCall = 5014, //!< routine undefined
|
||||||
|
CBotErrNoDoubleDots = 5015, //!< " : " expected
|
||||||
|
CBotErrNoWhile = 5016, //!< "while" expected (in do..while)
|
||||||
|
CBotErrBreakOutside = 5017, //!< break outside of a loop
|
||||||
|
CBotErrUndefLabel = 5019, //!< label udnefined
|
||||||
|
CBotErrLabel = 5018, //!< label ne peut se mettre ici (label can not get here)
|
||||||
|
CBotErrNoCase = 5020, //!< missing " case "
|
||||||
|
CBotErrBadNum = 5021, //!< expected number
|
||||||
|
CBotErrVoid = 5022, //!< " void " not possible here
|
||||||
|
CBotErrNoType = 5023, //!< type declaration expected
|
||||||
|
CBotErrNoVar = 5024, //!< variable name expected
|
||||||
|
CBotErrNoFunc = 5025, //!< expected function name
|
||||||
|
CBotErrOverParam = 5026, //!< too many parameters
|
||||||
|
CBotErrRedefFunc = 5027, //!< this function already exists
|
||||||
|
CBotErrLowParam = 5028, //!< not enough parameters
|
||||||
|
CBotErrBadParam = 5029, //!< wrong types of parameters
|
||||||
|
CBotErrNbParam = 5030, //!< wrong number of parameters
|
||||||
|
CBotErrUndefItem = 5031, //!< element does not exist in the class
|
||||||
|
CBotErrUndefClass = 5032, //!< variable is not a class
|
||||||
|
CBotErrNoConstruct = 5033, //!< no appropriate constructor
|
||||||
|
CBotErrRedefClass = 5034, //!< class already exists
|
||||||
|
CBotErrCloseIndex = 5035, //!< " ] " expected
|
||||||
|
CBotErrReserved = 5036, //!< reserved word (for a DefineNum)
|
||||||
|
CBotErrBadNew = 5037, //!< wrong setting for new
|
||||||
|
CBotErrOpenIndex = 5038, //!< " [ " expected
|
||||||
|
CBotErrBadString = 5039, //!< expected string
|
||||||
|
CBotErrBadIndex = 5040, //!< wrong index type "[ false ]"
|
||||||
|
CBotErrPrivate = 5041, //!< protected item
|
||||||
|
CBotErrNoPublic = 5042, //!< missing word "public"
|
||||||
|
|
||||||
|
// Runtime errors
|
||||||
|
CBotErrZeroDiv = 6000, //!< division by zero
|
||||||
|
CBotErrNotInit = 6001, //!< uninitialized variable
|
||||||
|
CBotErrBadThrow = 6002, //!< throw a negative value
|
||||||
|
CBotErrNoRetVal = 6003, //!< function did not return results
|
||||||
|
CBotErrNoRun = 6004, //!< Run() without active function
|
||||||
|
CBotErrUndefFunc = 6005, //!< calling a function that no longer exists
|
||||||
|
CBotErrNotClass = 6006, //!< this class does not exist
|
||||||
|
CBotErrNull = 6007, //!< null pointer
|
||||||
|
CBotErrNan = 6008, //!< calculation with a NAN
|
||||||
|
CBotErrOutArray = 6009, //!< index out of array
|
||||||
|
CBotErrStackOver = 6010, //!< stack overflow
|
||||||
|
CBotErrDeletedPtr = 6011, //!< pointer to an object destroyed
|
||||||
|
CBotErrFileOpen = 6012, //!< cannot open the file
|
||||||
|
CBotErrNotOpen = 6013, //!< channel not open
|
||||||
|
CBotErrRead = 6014, //!< error while reading
|
||||||
|
CBotErrWrite = 6015, //!< writing error
|
||||||
|
|
||||||
|
CBotErrMAX, //!< Max errors
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,171 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExternalCall.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotToken.h"
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
void CBotExternalCallList::Clear()
|
||||||
|
{
|
||||||
|
m_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBotExternalCallList::AddFunction(const std::string& name, std::unique_ptr<CBotExternalCall> call)
|
||||||
|
{
|
||||||
|
m_list[name] = std::move(call);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotTypResult CBotExternalCallList::CompileCall(CBotToken*& p, CBotVar* thisVar, CBotVar** ppVar, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
if (m_list.count(p->GetString()) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
CBotExternalCall* pt = m_list[p->GetString()].get();
|
||||||
|
|
||||||
|
std::unique_ptr<CBotVar> args = std::unique_ptr<CBotVar>(MakeListVars(ppVar));
|
||||||
|
CBotTypResult r = pt->Compile(thisVar, args.get(), m_user);
|
||||||
|
|
||||||
|
// if a class is returned, it is actually a pointer
|
||||||
|
if (r.GetType() == CBotTypClass) r.SetType(CBotTypPointer);
|
||||||
|
|
||||||
|
if (r.GetType() > CBotTypMAX) // error?
|
||||||
|
{
|
||||||
|
pStack->SetError(static_cast<CBotError>(r.GetType()), p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotExternalCallList::SetUserPtr(void* pUser)
|
||||||
|
{
|
||||||
|
m_user = pUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBotExternalCallList::CheckCall(const std::string& name)
|
||||||
|
{
|
||||||
|
return m_list.count(name) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CBotExternalCallList::DoCall(CBotToken* token, CBotVar* thisVar, CBotVar** ppVar, CBotStack* pStack,
|
||||||
|
const CBotTypResult& rettype)
|
||||||
|
{
|
||||||
|
if (token == nullptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (m_list.count(token->GetString()) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
CBotExternalCall* pt = m_list[token->GetString()].get();
|
||||||
|
|
||||||
|
if (pStack->IsCallFinished()) return true;
|
||||||
|
CBotStack* pile = pStack->AddStackExternalCall(pt);
|
||||||
|
|
||||||
|
// lists the parameters depending on the contents of the stack (pStackVar)
|
||||||
|
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||||
|
|
||||||
|
// creates a variable to the result
|
||||||
|
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
|
||||||
|
|
||||||
|
pile->SetVar(pVar);
|
||||||
|
|
||||||
|
CBotStack* pile2 = pile->AddStack();
|
||||||
|
pile2->SetVar(pResult);
|
||||||
|
|
||||||
|
pile->SetError(CBotNoErr, token); // save token for the position in case of error
|
||||||
|
return pt->Run(thisVar, pStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBotExternalCallList::RestoreCall(CBotToken* token, CBotVar* thisVar, CBotVar** ppVar, CBotStack* pStack)
|
||||||
|
{
|
||||||
|
if (m_list.count(token->GetString()) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CBotExternalCall* pt = m_list[token->GetString()].get();
|
||||||
|
|
||||||
|
CBotStack* pile = pStack->RestoreStackEOX(pt);
|
||||||
|
if (pile == nullptr) return true;
|
||||||
|
|
||||||
|
pile->RestoreStack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CBotExternalCall::CBotExternalCall()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotExternalCall::~CBotExternalCall()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CBotExternalCallDefault::CBotExternalCallDefault(RuntimeFunc rExec, CompileFunc rCompile)
|
||||||
|
{
|
||||||
|
m_rExec = rExec;
|
||||||
|
m_rComp = rCompile;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotExternalCallDefault::~CBotExternalCallDefault()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotTypResult CBotExternalCallDefault::Compile(CBotVar* thisVar, CBotVar* args, void* user)
|
||||||
|
{
|
||||||
|
return m_rComp(args, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBotExternalCallDefault::Run(CBotVar* thisVar, CBotStack* pStack)
|
||||||
|
{
|
||||||
|
if (pStack->IsCallFinished()) return true;
|
||||||
|
CBotStack* pile = pStack->AddStackExternalCall(this);
|
||||||
|
CBotVar* args = pile->GetVar();
|
||||||
|
|
||||||
|
CBotStack* pile2 = pile->AddStack();
|
||||||
|
|
||||||
|
CBotVar* result = pile2->GetVar();
|
||||||
|
|
||||||
|
int exception = CBotNoErr; // TODO: Change to CBotError
|
||||||
|
bool res = m_rExec(args, result, exception, pStack->GetUserPtr());
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
if (exception != CBotNoErr)
|
||||||
|
{
|
||||||
|
pStack->SetError(static_cast<CBotError>(exception));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != nullptr) pStack->SetCopyVar(result);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,189 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotUtils.h"
|
||||||
|
#include "CBot/CBotEnums.h"
|
||||||
|
#include "CBot/CBotDefines.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotStack;
|
||||||
|
class CBotCStack;
|
||||||
|
class CBotVar;
|
||||||
|
class CBotTypResult;
|
||||||
|
class CBotToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Interface for external CBot calls
|
||||||
|
*
|
||||||
|
* \see CBotExternalCallList
|
||||||
|
* \see CBotExternalCallDefault
|
||||||
|
*/
|
||||||
|
class CBotExternalCall
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* \brief Constructor
|
||||||
|
* \see CBotProgram::AddFunction()
|
||||||
|
*/
|
||||||
|
CBotExternalCall();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CBotExternalCall();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Compile the function
|
||||||
|
*
|
||||||
|
* \param thisVar "this" variable for class calls, nullptr for normal calls
|
||||||
|
* \param args Arguments (only types!) passed to the function
|
||||||
|
* \param user User pointer provided to CBotProgram::Compile()
|
||||||
|
*/
|
||||||
|
virtual CBotTypResult Compile(CBotVar* thisVar, CBotVar* args, void* user) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Execute the function
|
||||||
|
*
|
||||||
|
* \param thisVar "this" variable for class calls, nullptr for normal calls
|
||||||
|
* \param pStack Stack to execute the function on
|
||||||
|
* \return false to request program interruption, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool Run(CBotVar* thisVar, CBotStack* pStack) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Default implementation of CBot external call, using compilation and runtime functions
|
||||||
|
*/
|
||||||
|
class CBotExternalCallDefault : public CBotExternalCall
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef bool (*RuntimeFunc)(CBotVar* args, CBotVar* result, int& exception, void* user);
|
||||||
|
typedef CBotTypResult (*CompileFunc)(CBotVar*& args, void* user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Constructor
|
||||||
|
* \param rExec Runtime function
|
||||||
|
* \param rCompile Compilation function
|
||||||
|
* \see CBotProgram::AddFunction()
|
||||||
|
*/
|
||||||
|
CBotExternalCallDefault(RuntimeFunc rExec, CompileFunc rCompile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CBotExternalCallDefault();
|
||||||
|
|
||||||
|
virtual CBotTypResult Compile(CBotVar* thisVar, CBotVar* args, void* user) override;
|
||||||
|
virtual bool Run(CBotVar* thisVar, CBotStack* pStack) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RuntimeFunc m_rExec;
|
||||||
|
CompileFunc m_rComp;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Class for mangaging CBot external calls
|
||||||
|
*
|
||||||
|
* \see CBotProgram::AddFunction() for information on how to add your functions to this list
|
||||||
|
*/
|
||||||
|
class CBotExternalCallList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* \brief Add a new function to the list
|
||||||
|
* \param name Function name
|
||||||
|
* \param call Function to add
|
||||||
|
* \return true
|
||||||
|
*/
|
||||||
|
bool AddFunction(const std::string& name, std::unique_ptr<CBotExternalCall> call);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Find and call compile function
|
||||||
|
*
|
||||||
|
* This function sets an error in compilation stack in case of failure
|
||||||
|
*
|
||||||
|
* \param p Token representing the function name
|
||||||
|
* \param thisVar "this" variable for class calls, nullptr for normal calls
|
||||||
|
* \param ppVars List of arguments (only types!)
|
||||||
|
* \param pStack Compilation stack
|
||||||
|
* \return CBotTypResult representing the return type of the function (::CBotType), or an error (::CBotError)
|
||||||
|
*/
|
||||||
|
CBotTypResult CompileCall(CBotToken*& p, CBotVar* thisVar, CBotVar** ppVars, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check if function with given name has been defined
|
||||||
|
* \param name Name to check
|
||||||
|
* \return true if function was defined
|
||||||
|
*/
|
||||||
|
bool CheckCall(const std::string& name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Find and call runtime function
|
||||||
|
*
|
||||||
|
* This function sets an error in runtime stack in case of failure
|
||||||
|
*
|
||||||
|
* \param token Token representing the function name
|
||||||
|
* \param thisVar "this" variable for class calls, nullptr for normal calls
|
||||||
|
* \param ppVars List of arguments
|
||||||
|
* \param pStack Runtime stack
|
||||||
|
* \param rettype Return type of the function, as returned by CompileCall()
|
||||||
|
* \return -1 if call failed (no such function), 0 if function requested interruption, 1 on success
|
||||||
|
*/
|
||||||
|
int DoCall(CBotToken* token, CBotVar* thisVar, CBotVar** ppVars, CBotStack* pStack, const CBotTypResult& rettype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Restore execution status after loading saved state
|
||||||
|
*
|
||||||
|
* \param token Token representing the function name
|
||||||
|
* \param thisVar "this" variable for class calls, nullptr for normal calls
|
||||||
|
* \param ppVar List of arguments
|
||||||
|
* \param pStack Runtime stack
|
||||||
|
* \return false on failure (e.g. function doesn't exist)
|
||||||
|
*/
|
||||||
|
bool RestoreCall(CBotToken* token, CBotVar* thisVar, CBotVar** ppVar, CBotStack* pStack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set user pointer to pass to compile functions
|
||||||
|
*
|
||||||
|
* This is for compile functions only, runtime functions use CBotStack::GetUserPtr()
|
||||||
|
*
|
||||||
|
* \param pUser User pointer
|
||||||
|
*/
|
||||||
|
void SetUserPtr(void* pUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Reset the list of registered functions
|
||||||
|
*/
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<std::string, std::unique_ptr<CBotExternalCall>> m_list{};
|
||||||
|
void* m_user = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,173 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotFileUtils.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotClass.h"
|
||||||
|
#include "CBot/CBotEnums.h"
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// file management
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
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();
|
||||||
|
if ( !WriteString(pf, p->GetName()) ) return false;
|
||||||
|
}
|
||||||
|
if ( type.Eq( CBotTypArrayBody ) ||
|
||||||
|
type.Eq( CBotTypArrayPointer ) )
|
||||||
|
{
|
||||||
|
if ( !WriteWord(pf, type.GetLimite()) ) return false;
|
||||||
|
if ( !WriteType(pf, type.GetTypElem()) ) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ReadType(FILE* pf, CBotTypResult &type)
|
||||||
|
{
|
||||||
|
unsigned short w, ww;
|
||||||
|
if ( !ReadWord(pf, w) ) return false;
|
||||||
|
type.SetType(w);
|
||||||
|
|
||||||
|
if ( type.Eq( CBotTypIntrinsic ) )
|
||||||
|
{
|
||||||
|
type = CBotTypResult( w, "point" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( type.Eq( CBotTypClass ) )
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
if ( !ReadString(pf, s) ) return false;
|
||||||
|
type = CBotTypResult( w, s );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( type.Eq( CBotTypArrayPointer ) ||
|
||||||
|
type.Eq( CBotTypArrayBody ) )
|
||||||
|
{
|
||||||
|
CBotTypResult r;
|
||||||
|
if ( !ReadWord(pf, ww) ) return false;
|
||||||
|
if ( !ReadType(pf, r) ) return false;
|
||||||
|
type = CBotTypResult( w, r );
|
||||||
|
type.SetLimite(static_cast<short>(ww));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
class CBotVar;
|
||||||
|
class CBotTypResult;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// routines for file management (* FILE)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief fOpen
|
||||||
|
* \param name
|
||||||
|
* \param mode
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
FILE* fOpen(const char* name, const char* mode);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool WriteWord(FILE* pf, unsigned short w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReadWord
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ReadWord(FILE* pf, unsigned short& w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReadLong
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ReadLong(FILE* pf, long& w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief WriteFloat
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool WriteFloat(FILE* pf, float w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief WriteLong
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool WriteLong(FILE* pf, long w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReadFloat
|
||||||
|
* \param pf
|
||||||
|
* \param w
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ReadFloat(FILE* pf, float& w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReadString
|
||||||
|
* \param pf
|
||||||
|
* \param s
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ReadString(FILE* pf, std::string& s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief WriteType
|
||||||
|
* \param pf
|
||||||
|
* \param type
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool WriteType(FILE* pf, const CBotTypResult &type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ReadType
|
||||||
|
* \param pf
|
||||||
|
* \param type
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ReadType(FILE* pf, CBotTypResult &type);
|
||||||
|
|
||||||
|
} // namespace CBot
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotBlock.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
#include "CBot/CBotInstr/CBotListInstr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotDefines.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal)
|
||||||
|
{
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPBLK))
|
||||||
|
{
|
||||||
|
CBotInstr* inst = CBotListInstr::Compile(p, pStack, bLocal);
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_CLBLK))
|
||||||
|
{
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStack->SetError(CBotErrCloseBlock, p->GetStart()); // missing parenthesis
|
||||||
|
delete inst;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStack->SetError(CBotErrOpenBlock, p->GetStart());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal)
|
||||||
|
{
|
||||||
|
// is this a new block
|
||||||
|
if (p->GetType() == ID_OPBLK) return CBotBlock::Compile(p, pStack);
|
||||||
|
|
||||||
|
// otherwise, look for a single statement instead
|
||||||
|
|
||||||
|
// to handle the case with local definition instruction (*)
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(p, bLocal);
|
||||||
|
|
||||||
|
return pStack->Return( CBotInstr::Compile(p, pStk), // a single instruction
|
||||||
|
pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (*) is the case in the following statement
|
||||||
|
// if (1 == 1) int x = 0;
|
||||||
|
// where the variable x is known only in the block following the if
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 An instruction block - { ... }
|
||||||
|
*
|
||||||
|
* There is never an instance of this class - it gets compiled into CBotListInstr
|
||||||
|
*
|
||||||
|
* \see CBotListInstr
|
||||||
|
*/
|
||||||
|
class CBotBlock : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Compiles a statement block - { instr; instr; }
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param bLocal
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Compiles a block of instructions or a single instruction
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param bLocal
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CBotBlock() = delete;
|
||||||
|
CBotBlock(const CBotBlock&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotBoolExpr.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotDefines.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotBoolExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
|
CBotInstr* inst = CBotTwoOpExpr::Compile(p, pStack);
|
||||||
|
|
||||||
|
if (nullptr != inst)
|
||||||
|
{
|
||||||
|
if (pStack->GetTypResult().Eq(CBotTypBoolean))
|
||||||
|
{
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrNotBoolean, p->GetStart()); // is not a boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
delete inst;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 An expression that results in a boolean value
|
||||||
|
*
|
||||||
|
* There is never an instance of this class - it gets compiled into CBotExpression
|
||||||
|
*
|
||||||
|
* \see CBotExpression
|
||||||
|
*/
|
||||||
|
class CBotBoolExpr : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CBotBoolExpr() = delete;
|
||||||
|
CBotBoolExpr(const CBotBoolExpr&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotBreak.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotBreak::CBotBreak()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotBreak::~CBotBreak()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotToken* pp = p; // preserves at the ^ token (starting position)
|
||||||
|
int type = p->GetType();
|
||||||
|
|
||||||
|
if (!IsOfType(p, ID_BREAK, ID_CONTINUE)) return nullptr; // should never happen
|
||||||
|
|
||||||
|
if ( !ChkLvl(std::string(), type ) )
|
||||||
|
{
|
||||||
|
pStack->SetError(CBotErrBreakOutside, pp);
|
||||||
|
return nullptr; // no object, the error is on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotBreak* inst = new CBotBreak(); // creates the object
|
||||||
|
inst->SetToken(pp); // keeps the operation
|
||||||
|
|
||||||
|
pp = p;
|
||||||
|
if ( IsOfType( p, TokenTypVar ) )
|
||||||
|
{
|
||||||
|
inst->m_label = pp->GetString(); // register the name of label
|
||||||
|
if ( !ChkLvl(inst->m_label, type ) )
|
||||||
|
{
|
||||||
|
delete inst;
|
||||||
|
pStack->SetError(CBotErrUndefLabel, pp);
|
||||||
|
return nullptr; // no object, the error is on the stack
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_SEP))
|
||||||
|
{
|
||||||
|
return inst; // return what it wants
|
||||||
|
}
|
||||||
|
delete inst;
|
||||||
|
|
||||||
|
pStack->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
return nullptr; // no object, the error is on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotBreak :: Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
// if ( pile == EOX ) return true;
|
||||||
|
|
||||||
|
if ( pile->IfStep() ) return false;
|
||||||
|
|
||||||
|
pile->SetBreak(m_token.GetType()==ID_BREAK ? 1 : 2, m_label);
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if ( bMain ) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotBreak::GetDebugData()
|
||||||
|
{
|
||||||
|
return !m_label.empty() ? "m_label = "+m_label : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Instructions "break" and "continue" (with an optional label)
|
||||||
|
*/
|
||||||
|
class CBotBreak : public CBotInstr
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBotBreak();
|
||||||
|
~CBotBreak();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execution of statement "break" or "continu"
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotBreak"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! A label if there is
|
||||||
|
std::string m_label;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotCase.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotExprLitNum.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCase::CBotCase()
|
||||||
|
{
|
||||||
|
m_value = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCase::~CBotCase()
|
||||||
|
{
|
||||||
|
delete m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCase* inst = new CBotCase(); // creates the object
|
||||||
|
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 ( pp->GetType() == ID_CASE )
|
||||||
|
{
|
||||||
|
pp = p;
|
||||||
|
inst->m_value = CBotExprLitNum::Compile(p, pStack);
|
||||||
|
if (inst->m_value == nullptr )
|
||||||
|
{
|
||||||
|
pStack->SetError( CBotErrBadNum, pp );
|
||||||
|
delete inst;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !IsOfType( p, ID_DOTS ))
|
||||||
|
{
|
||||||
|
pStack->SetError( CBotErrNoDoubleDots, p->GetStart() );
|
||||||
|
delete inst;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCase::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
return true; // the "case" statement does nothing!
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCase::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCase::CompCase(CBotStack* &pile, int val)
|
||||||
|
{
|
||||||
|
if (m_value == nullptr ) return true; // "default" case
|
||||||
|
|
||||||
|
while (!m_value->Execute(pile)); // puts the value on the correspondent stack (without interruption)
|
||||||
|
return (pile->GetVal() == val); // compared with the given value
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotCase::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_value"] = m_value;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Instruction "case", part of "switch" structure
|
||||||
|
*
|
||||||
|
* \see CBotSwitch
|
||||||
|
*/
|
||||||
|
class CBotCase : public CBotInstr
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBotCase();
|
||||||
|
~CBotCase();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execution of instruction "case".
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
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:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotCase"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Value to compare.
|
||||||
|
CBotInstr* m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotCatch.h"
|
||||||
|
#include "CBot/CBotInstr/CBotBlock.h"
|
||||||
|
#include "CBot/CBotInstr/CBotExpression.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCatch::CBotCatch()
|
||||||
|
{
|
||||||
|
m_cond = nullptr;
|
||||||
|
m_block = nullptr;
|
||||||
|
m_next = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCatch::~CBotCatch()
|
||||||
|
{
|
||||||
|
delete m_cond; // frees the list
|
||||||
|
delete m_block; // frees the instruction block
|
||||||
|
delete m_next; // and subsequent
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCatch* inst = new CBotCatch(); // creates the object
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
|
inst->SetToken(p);
|
||||||
|
if (!IsOfType(p, ID_CATCH)) return nullptr; // should never happen
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPENPAR))
|
||||||
|
{
|
||||||
|
inst->m_cond = CBotExpression::Compile(p, pStack);
|
||||||
|
if (( pStack->GetType() < CBotTypLong ||
|
||||||
|
pStack->GetTypResult().Eq(CBotTypBoolean) )&& pStack->IsOk() )
|
||||||
|
{
|
||||||
|
if (IsOfType(p, ID_CLOSEPAR))
|
||||||
|
{
|
||||||
|
inst->m_block = CBotBlock::CompileBlkOrInst(p, pStack );
|
||||||
|
if ( pStack->IsOk() )
|
||||||
|
return inst; // return an object to the application
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrClosePar, p->GetStart());
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrOpenPar, p->GetStart());
|
||||||
|
delete inst; // error, frees up
|
||||||
|
return nullptr; // no object, the error is on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCatch :: Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
if (m_block == nullptr ) return true;
|
||||||
|
return m_block->Execute(pj); // executes the associated block
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCatch :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if ( bMain && m_block != nullptr ) m_block->RestoreState(pj, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCatch :: RestoreCondState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
m_cond->RestoreState(pj, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
||||||
|
{
|
||||||
|
if ( !m_cond->Execute(pile) ) return false;
|
||||||
|
|
||||||
|
if ( val > 0 || pile->GetVar() == nullptr || pile->GetVar()->GetType() != CBotTypBoolean )
|
||||||
|
{
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypBoolean);
|
||||||
|
var->SetValInt( pile->GetVal() == val );
|
||||||
|
pile->SetVar(var); // calls on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotCatch::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_block"] = m_block;
|
||||||
|
links["m_cond"] = m_cond;
|
||||||
|
links["m_next"] = m_next;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Instruction "catch", part of "try" structure
|
||||||
|
*
|
||||||
|
* \see CBotTry
|
||||||
|
*/
|
||||||
|
class CBotCatch : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotCatch();
|
||||||
|
~CBotCatch();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotCatch* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief TestCatch Routine to see if the catch is to do or not.
|
||||||
|
* \param pj
|
||||||
|
* \param val
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool TestCatch(CBotStack* &pj, int val);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execution of "catch".
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreCondState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreCondState(CBotStack* &pj, bool bMain);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotCatch"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Instructions
|
||||||
|
CBotInstr* m_block;
|
||||||
|
//! Condition
|
||||||
|
CBotInstr* m_cond;
|
||||||
|
//! Following catch
|
||||||
|
CBotCatch* m_next;
|
||||||
|
|
||||||
|
friend class CBotTry;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotCondition.h"
|
||||||
|
#include "CBot/CBotInstr/CBotBoolExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotDefines.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotCondition::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
if (IsOfType(p, ID_OPENPAR))
|
||||||
|
{
|
||||||
|
CBotInstr* inst = CBotBoolExpr::Compile(p, pStack);
|
||||||
|
if (nullptr != inst)
|
||||||
|
{
|
||||||
|
if (IsOfType(p, ID_CLOSEPAR))
|
||||||
|
{
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
pStack->SetError(CBotErrClosePar, p->GetStart()); // missing parenthesis
|
||||||
|
}
|
||||||
|
delete inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStack->SetError(CBotErrOpenPar, p->GetStart()); // missing parenthesis
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 condition - boolean expression enclosed in brackets - (condition)
|
||||||
|
*
|
||||||
|
* There is never an instance of this class - it gets compiled into CBotExpression
|
||||||
|
*
|
||||||
|
* \see CBotBoolExpr
|
||||||
|
* \see CBotExpression
|
||||||
|
*/
|
||||||
|
class CBotCondition : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile Compile a statement such as "(condition)" the condition
|
||||||
|
* must be Boolean
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CBotCondition() = delete;
|
||||||
|
CBotCondition(const CBotCondition&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,257 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefArray.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotExpression.h"
|
||||||
|
#include "CBot/CBotInstr/CBotListArray.h"
|
||||||
|
#include "CBot/CBotInstr/CBotEmpty.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
#include "CBot/CBotDefines.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefArray::CBotDefArray()
|
||||||
|
{
|
||||||
|
m_var = nullptr;
|
||||||
|
m_listass = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefArray::~CBotDefArray()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
delete m_listass;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type)
|
||||||
|
{
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(p);
|
||||||
|
|
||||||
|
CBotDefArray* inst = new CBotDefArray();
|
||||||
|
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
inst->SetToken(vartoken);
|
||||||
|
|
||||||
|
// determinse the expression is valid for the item on the left side
|
||||||
|
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable?
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotInstr* i;
|
||||||
|
while (IsOfType(p, ID_OPBRK))
|
||||||
|
{
|
||||||
|
if (p->GetType() != ID_CLBRK)
|
||||||
|
i = CBotExpression::Compile(p, pStk); // expression for the value
|
||||||
|
else
|
||||||
|
i = new CBotEmpty(); // if no special formula
|
||||||
|
|
||||||
|
inst->AddNext3b(i); // construct a list
|
||||||
|
type = CBotTypResult(CBotTypArrayPointer, type);
|
||||||
|
|
||||||
|
if (!pStk->IsOk() || !IsOfType(p, ID_CLBRK ))
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create(*vartoken, type); // create an instance
|
||||||
|
inst->m_typevar = type;
|
||||||
|
|
||||||
|
var->SetUniqNum(
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
pStack->AddVar(var); // place it on the stack
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS)) // with an assignment
|
||||||
|
{
|
||||||
|
if ((inst->m_listass = CBotTwoOpExpr::Compile(p, pStk)) != nullptr)
|
||||||
|
{
|
||||||
|
if (!pStk->GetTypResult().Compare(type)) // compatible type ?
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inst->m_listass = CBotListArray::Compile(p, pStk, type.GetTypElem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pStk->IsOk()) return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefArray::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile1 = pj->AddStack(this);
|
||||||
|
|
||||||
|
CBotStack* pile = pile1;
|
||||||
|
|
||||||
|
if (pile1->GetState() == 0)
|
||||||
|
{
|
||||||
|
// seek the maximum dimension of the table
|
||||||
|
CBotInstr* p = GetNext3b(); // the different formulas
|
||||||
|
int nb = 0;
|
||||||
|
|
||||||
|
while (p != nullptr)
|
||||||
|
{
|
||||||
|
pile = pile->AddStack(); // little room to work
|
||||||
|
nb++;
|
||||||
|
if (pile->GetState() == 0)
|
||||||
|
{
|
||||||
|
if (!p->Execute(pile)) return false; // size calculation //interrupted?
|
||||||
|
pile->IncState();
|
||||||
|
}
|
||||||
|
p = p->GetNext3b();
|
||||||
|
}
|
||||||
|
|
||||||
|
p = GetNext3b();
|
||||||
|
pile = pile1; // returns to the stack
|
||||||
|
int n = 0;
|
||||||
|
int max[100];
|
||||||
|
|
||||||
|
while (p != nullptr)
|
||||||
|
{
|
||||||
|
pile = pile->AddStack();
|
||||||
|
CBotVar* v = pile->GetVar(); // result
|
||||||
|
max[n] = v->GetValInt(); // value
|
||||||
|
if (max[n]>MAXARRAYSIZE)
|
||||||
|
{
|
||||||
|
pile->SetError(CBotErrOutArray, &m_token);
|
||||||
|
return pj->Return (pile);
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
p = p->GetNext3b();
|
||||||
|
}
|
||||||
|
while (n<100) max[n++] = 0;
|
||||||
|
|
||||||
|
m_typevar.SetArray(max); // store the limitations
|
||||||
|
|
||||||
|
// create simply a nullptr pointer
|
||||||
|
CBotVar* var = CBotVar::Create(*(m_var->GetToken()), m_typevar);
|
||||||
|
var->SetPointer(nullptr);
|
||||||
|
var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||||
|
pj->AddVar(var);
|
||||||
|
|
||||||
|
#if STACKMEM
|
||||||
|
pile1->AddStack()->Delete();
|
||||||
|
#else
|
||||||
|
delete pile1->AddStack(); // need more indices
|
||||||
|
#endif
|
||||||
|
pile1->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile1->GetState() == 1)
|
||||||
|
{
|
||||||
|
if (m_listass != nullptr) // there is the assignment for this table
|
||||||
|
{
|
||||||
|
CBotVar* pVar = pj->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent, false);
|
||||||
|
|
||||||
|
if (!m_listass->Execute(pile1, pVar)) return false;
|
||||||
|
}
|
||||||
|
pile1->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile1->IfStep()) return false;
|
||||||
|
|
||||||
|
if ( m_next2b &&
|
||||||
|
!m_next2b->Execute(pile1 )) return false;
|
||||||
|
|
||||||
|
return pj->Return(pile1);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefArray::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotStack* pile1 = pj;
|
||||||
|
|
||||||
|
CBotVar* var = pj->FindVar(m_var->GetToken()->GetString());
|
||||||
|
if (var != nullptr) var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||||
|
|
||||||
|
if (bMain)
|
||||||
|
{
|
||||||
|
pile1 = pj->RestoreStack(this);
|
||||||
|
CBotStack* pile = pile1;
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
if (pile1->GetState() == 0)
|
||||||
|
{
|
||||||
|
// seek the maximum dimension of the table
|
||||||
|
CBotInstr* p = GetNext3b();
|
||||||
|
|
||||||
|
while (p != nullptr)
|
||||||
|
{
|
||||||
|
pile = pile->RestoreStack();
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
if (pile->GetState() == 0)
|
||||||
|
{
|
||||||
|
p->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p = p->GetNext3b();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pile1->GetState() == 1 && m_listass != nullptr)
|
||||||
|
{
|
||||||
|
m_listass->RestoreState(pile1, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_next2b ) m_next2b->RestoreState( pile1, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotDefArray::GetDebugData()
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << m_typevar.ToString();
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefArray::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_listass"] = m_listass;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of an array (of any type)
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* \code
|
||||||
|
* int a[12];
|
||||||
|
* float x[];
|
||||||
|
* bool[] z;
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
class CBotDefArray : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDefArray();
|
||||||
|
~CBotDefArray();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param type
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes the definition of an array.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDefArray"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! The variables to initialize.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! List of assignments for array.
|
||||||
|
CBotInstr* m_listass;
|
||||||
|
//! Type of elements.
|
||||||
|
CBotTypResult m_typevar;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefBoolean.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
#include "CBot/CBotInstr/CBotDefArray.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefBoolean::CBotDefBoolean()
|
||||||
|
{
|
||||||
|
m_var = m_expr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefBoolean::~CBotDefBoolean()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
delete m_expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip)
|
||||||
|
{
|
||||||
|
CBotToken* pp = cont ? nullptr : p;
|
||||||
|
|
||||||
|
if (!cont && !IsOfType(p, ID_BOOLEAN, ID_BOOL)) return nullptr;
|
||||||
|
|
||||||
|
CBotDefBoolean* inst = static_cast<CBotDefBoolean*>(CompileArray(p, pStack, CBotTypBoolean));
|
||||||
|
if (inst != nullptr || !pStack->IsOk()) return inst;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||||
|
|
||||||
|
inst = new CBotDefBoolean();
|
||||||
|
|
||||||
|
inst->m_expr = nullptr;
|
||||||
|
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
inst->SetToken(vartoken);
|
||||||
|
CBotVar* var = nullptr;
|
||||||
|
|
||||||
|
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypBoolean;
|
||||||
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPBRK))
|
||||||
|
{
|
||||||
|
delete inst; // type is not CBotDefInt
|
||||||
|
p = vartoken; // resutns to the variable name
|
||||||
|
|
||||||
|
// compiles an array declaration
|
||||||
|
|
||||||
|
inst = static_cast<CBotDefBoolean*>(CBotDefArray::Compile(p, pStk, CBotTypBoolean));
|
||||||
|
|
||||||
|
if (!pStk->IsOk() )
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
goto suite; // no assignment, variable already created
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS))
|
||||||
|
{
|
||||||
|
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (!pStk->GetTypResult().Eq(CBotTypBoolean))
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var = CBotVar::Create(*vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment)
|
||||||
|
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
|
||||||
|
var->SetUniqNum(
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
pStack->AddVar(var);
|
||||||
|
suite:
|
||||||
|
if (IsOfType(p, ID_COMMA))
|
||||||
|
{
|
||||||
|
if (nullptr != ( inst->m_next2b = CBotDefBoolean::Compile(p, pStk, true, noskip)))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noskip || IsOfType(p, ID_SEP))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefBoolean::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);//essential for SetState()
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr && !m_expr->Execute(pile)) return false;
|
||||||
|
m_var->Execute(pile);
|
||||||
|
|
||||||
|
if (!pile->SetState(1)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
if ( m_next2b &&
|
||||||
|
!m_next2b->Execute(pile)) return false;
|
||||||
|
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefBoolean::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
if (bMain)
|
||||||
|
{
|
||||||
|
pile = pj->RestoreStack(this);
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr) m_expr->RestoreState(pile, bMain); // initial value interrupted?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_var->RestoreState(pile, bMain);
|
||||||
|
|
||||||
|
if (m_next2b)
|
||||||
|
m_next2b->RestoreState(pile, bMain); // other(s) definition(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefBoolean::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of boolean variable - bool a, b = false
|
||||||
|
*/
|
||||||
|
class CBotDefBoolean : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDefBoolean();
|
||||||
|
~CBotDefBoolean();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param cont
|
||||||
|
* \param noskip
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes a boolean variable definition.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDefBoolean"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Variable to initialise.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! A value to put, if there is.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,448 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefClass.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotInstrUtils.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
#include "CBot/CBotInstr/CBotDefArray.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
#include "CBot/CBotClass.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVarPointer.h"
|
||||||
|
#include "CBot/CBotVar/CBotVarClass.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefClass::CBotDefClass()
|
||||||
|
{
|
||||||
|
m_next = nullptr;
|
||||||
|
m_var = nullptr;
|
||||||
|
m_parameters = nullptr;
|
||||||
|
m_expr = nullptr;
|
||||||
|
m_hasParams = false;
|
||||||
|
m_nMethodeIdent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefClass::~CBotDefClass()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass)
|
||||||
|
{
|
||||||
|
// seeks the corresponding classes
|
||||||
|
if ( pClass == nullptr )
|
||||||
|
{
|
||||||
|
pStack->SetStartError(p->GetStart());
|
||||||
|
pClass = CBotClass::Find(p);
|
||||||
|
if ( pClass == nullptr )
|
||||||
|
{
|
||||||
|
// not found? is bizare
|
||||||
|
pStack->SetError(CBotErrNotClass, p);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
p = p->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bIntrinsic = pClass->IsIntrinsic();
|
||||||
|
CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass );
|
||||||
|
CBotDefClass* inst = static_cast<CBotDefClass*>(CompileArray(p, pStack, type));
|
||||||
|
if ( inst != nullptr || !pStack->IsOk() ) return inst;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
|
||||||
|
inst = new CBotDefClass();
|
||||||
|
/// TODO Need to be revised and fixed after adding unit tests
|
||||||
|
CBotToken token(pClass->GetName(), std::string(), p->GetStart(), p->GetEnd());
|
||||||
|
inst->SetToken(&token);
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
|
||||||
|
if ( nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) )
|
||||||
|
{
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = type;
|
||||||
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||||
|
{
|
||||||
|
pStk->SetStartError(vartoken->GetStart());
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken->GetEnd());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPBRK)) // with any clues?
|
||||||
|
{
|
||||||
|
delete inst; // is not type CBotDefInt
|
||||||
|
p = vartoken; // returns to the variable name
|
||||||
|
|
||||||
|
// compiles declaration an array
|
||||||
|
|
||||||
|
inst = static_cast<CBotDefClass*>(CBotDefArray::Compile(p, pStk, type ));
|
||||||
|
|
||||||
|
if (!pStk->IsOk() )
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
goto suite; // no assignment, variable already created
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CBotVar* var;
|
||||||
|
var = CBotVar::Create(vartoken->GetString(), type); // creates the instance
|
||||||
|
// var->SetClass(pClass);
|
||||||
|
var->SetUniqNum(
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
// its attribute a unique number
|
||||||
|
pStack->AddVar(var); // placed on the stack
|
||||||
|
|
||||||
|
// look if there are parameters
|
||||||
|
inst->m_hasParams = (p->GetType() == ID_OPENPAR);
|
||||||
|
|
||||||
|
CBotVar* ppVars[1000];
|
||||||
|
inst->m_parameters = CompileParams(p, pStk, ppVars);
|
||||||
|
if ( !pStk->IsOk() ) goto error;
|
||||||
|
|
||||||
|
// if there are parameters, is the equivalent to the stament "new"
|
||||||
|
// CPoint A ( 0, 0 ) is equivalent to
|
||||||
|
// CPoint A = new CPoint( 0, 0 )
|
||||||
|
|
||||||
|
// if ( nullptr != inst->m_parameters )
|
||||||
|
if ( inst->m_hasParams )
|
||||||
|
{
|
||||||
|
// the constructor is there?
|
||||||
|
// std::string noname;
|
||||||
|
CBotTypResult r = pClass->CompileMethode(pClass->GetName(), var, ppVars, pStk, inst->m_nMethodeIdent);
|
||||||
|
delete pStk->TokenStack(); // releases the supplement stack
|
||||||
|
int typ = r.GetType();
|
||||||
|
|
||||||
|
if (typ == CBotErrUndefCall)
|
||||||
|
{
|
||||||
|
// si le constructeur n'existe pas
|
||||||
|
if (inst->m_parameters != nullptr) // with parameters
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrNoConstruct, vartoken);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
typ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typ>20)
|
||||||
|
{
|
||||||
|
pStk->SetError(static_cast<CBotError>(typ), vartoken->GetEnd());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS)) // with a assignment?
|
||||||
|
{
|
||||||
|
if (inst->m_hasParams)
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) )
|
||||||
|
{
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
CBotClass* result = pStk->GetClass();
|
||||||
|
if ( !pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_POINTER).Eq(CBotTypNullPointer) &&
|
||||||
|
( !pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_POINTER).Eq(CBotTypPointer) ||
|
||||||
|
( result != nullptr && !pClass->IsChildOf(result) ))) // type compatible ?
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
// if ( !bIntrinsic ) var->SetPointer(pStk->GetVar()->GetPointer());
|
||||||
|
if ( !bIntrinsic )
|
||||||
|
{
|
||||||
|
// does not use the result on the stack, to impose the class
|
||||||
|
CBotVar* pvar = CBotVar::Create("", pClass);
|
||||||
|
var->SetPointer( pvar ); // variable already declared instance pointer
|
||||||
|
delete pvar; // removes the second pointer
|
||||||
|
}
|
||||||
|
var->SetInit(CBotVar::InitType::DEF); // marks the pointer as init
|
||||||
|
}
|
||||||
|
else if (inst->m_hasParams)
|
||||||
|
{
|
||||||
|
// creates the object on the stack
|
||||||
|
// with a pointer to the object
|
||||||
|
if ( !bIntrinsic )
|
||||||
|
{
|
||||||
|
CBotVar* pvar = CBotVar::Create("", pClass);
|
||||||
|
var->SetPointer( pvar ); // variable already declared instance pointer
|
||||||
|
delete pvar; // removes the second pointer
|
||||||
|
}
|
||||||
|
var->SetInit(CBotVar::InitType::IS_POINTER); // marks the pointer as init
|
||||||
|
}
|
||||||
|
suite:
|
||||||
|
if (IsOfType(p, ID_COMMA)) // several chained definitions
|
||||||
|
{
|
||||||
|
if ( nullptr != ( inst->m_next = CBotDefClass::Compile(p, pStk, pClass) )) // compiles the following
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_SEP)) // complete instruction
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefClass::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotVar* pThis = nullptr;
|
||||||
|
|
||||||
|
CBotStack* pile = pj->AddStack(this);//essential for SetState()
|
||||||
|
// if ( pile == EOX ) return true;
|
||||||
|
|
||||||
|
CBotToken* pt = &m_token;
|
||||||
|
CBotClass* pClass = CBotClass::Find(pt);
|
||||||
|
|
||||||
|
bool bIntrincic = pClass->IsIntrinsic();
|
||||||
|
|
||||||
|
// creates the variable of type pointer to the object
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
std::string name = m_var->m_token.GetString();
|
||||||
|
if ( bIntrincic )
|
||||||
|
{
|
||||||
|
pThis = CBotVar::Create(name, CBotTypResult( CBotTypIntrinsic, pClass ));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pThis = CBotVar::Create(name, CBotTypResult( CBotTypPointer, pClass ));
|
||||||
|
}
|
||||||
|
|
||||||
|
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute as unique number
|
||||||
|
pile->AddVar(pThis); // place on the stack
|
||||||
|
pile->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pThis == nullptr ) pThis = pile->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent, false);
|
||||||
|
|
||||||
|
if ( pile->GetState()<3)
|
||||||
|
{
|
||||||
|
// ss there an assignment or parameters (contructor)
|
||||||
|
|
||||||
|
// CBotVarClass* pInstance = nullptr;
|
||||||
|
|
||||||
|
if ( m_expr != nullptr )
|
||||||
|
{
|
||||||
|
// evaluates the expression for the assignment
|
||||||
|
if (!m_expr->Execute(pile)) return false;
|
||||||
|
|
||||||
|
if ( bIntrincic )
|
||||||
|
{
|
||||||
|
CBotVar* pv = pile->GetVar();
|
||||||
|
if ( pv == nullptr || pv->GetPointer() == nullptr )
|
||||||
|
{
|
||||||
|
pile->SetError(CBotErrNull, &m_token);
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
pThis->Copy(pile->GetVar(), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CBotVarClass* pInstance;
|
||||||
|
pInstance = (static_cast<CBotVarPointer*>(pile->GetVar()))->GetPointer(); // value for the assignment
|
||||||
|
pThis->SetPointer(pInstance);
|
||||||
|
}
|
||||||
|
pThis->SetInit(CBotVar::InitType::DEF);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( m_hasParams )
|
||||||
|
{
|
||||||
|
// evaluates the constructor of an instance
|
||||||
|
|
||||||
|
if ( !bIntrincic && pile->GetState() == 1)
|
||||||
|
{
|
||||||
|
CBotToken* pt = &m_token;
|
||||||
|
CBotClass* pClass = CBotClass::Find(pt);
|
||||||
|
|
||||||
|
// creates an instance of the requested class
|
||||||
|
|
||||||
|
CBotVarClass* pInstance;
|
||||||
|
pInstance = static_cast<CBotVarClass*>(CBotVar::Create("", pClass));
|
||||||
|
pThis->SetPointer(pInstance);
|
||||||
|
delete pInstance;
|
||||||
|
|
||||||
|
pile->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar* ppVars[1000];
|
||||||
|
CBotStack* pile2 = pile;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
CBotInstr* p = m_parameters;
|
||||||
|
// evaluates the parameters
|
||||||
|
// and places the values on the stack
|
||||||
|
// to (can) be interrupted (broken) at any time
|
||||||
|
|
||||||
|
if ( p != nullptr) while ( true )
|
||||||
|
{
|
||||||
|
pile2 = pile2->AddStack(); // place on the stack for the results
|
||||||
|
if ( pile2->GetState() == 0 )
|
||||||
|
{
|
||||||
|
if (!p->Execute(pile2)) return false; // interrupted here?
|
||||||
|
pile2->SetState(1);
|
||||||
|
}
|
||||||
|
ppVars[i++] = pile2->GetVar();
|
||||||
|
p = p->GetNext();
|
||||||
|
if ( p == nullptr) break;
|
||||||
|
}
|
||||||
|
ppVars[i] = nullptr;
|
||||||
|
|
||||||
|
// creates a variable for the result
|
||||||
|
CBotVar* pResult = nullptr; // constructor still void
|
||||||
|
|
||||||
|
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||||
|
pThis, ppVars,
|
||||||
|
pResult, pile2, GetToken())) return false; // interrupt
|
||||||
|
|
||||||
|
pThis->SetInit(CBotVar::InitType::DEF);
|
||||||
|
pThis->ConstructorSet(); // indicates that the constructor has been called
|
||||||
|
pile->Return(pile2); // releases a piece of stack
|
||||||
|
|
||||||
|
// pInstance = pThis->GetPointer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ( !bIntrincic ) pThis->SetPointer(pInstance); // a pointer to the instance
|
||||||
|
|
||||||
|
pile->SetState(3); // finished this part
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pile->IfStep() ) return false;
|
||||||
|
|
||||||
|
if ( m_next2b != nullptr &&
|
||||||
|
!m_next2b->Execute(pile)) return false; // other (s) definition (s)
|
||||||
|
|
||||||
|
return pj->Return( pile ); // transmits below (further)
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefClass::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotVar* pThis = nullptr;
|
||||||
|
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
if ( bMain ) pile = pj->RestoreStack(this);
|
||||||
|
if ( pile == nullptr ) return;
|
||||||
|
|
||||||
|
// creates the variable of type pointer to the object
|
||||||
|
{
|
||||||
|
std::string name = m_var->m_token.GetString();
|
||||||
|
pThis = pile->FindVar(name);
|
||||||
|
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute a unique number
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotToken* pt = &m_token;
|
||||||
|
CBotClass* pClass = CBotClass::Find(pt);
|
||||||
|
bool bIntrincic = pClass->IsIntrinsic();
|
||||||
|
|
||||||
|
if ( bMain && pile->GetState()<3)
|
||||||
|
{
|
||||||
|
// is there an assignment or parameters (constructor)
|
||||||
|
|
||||||
|
// CBotVarClass* pInstance = nullptr;
|
||||||
|
|
||||||
|
if ( m_expr != nullptr )
|
||||||
|
{
|
||||||
|
// evaluates the expression for the assignment
|
||||||
|
m_expr->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( m_hasParams )
|
||||||
|
{
|
||||||
|
// evaluates the constructor of an instance
|
||||||
|
|
||||||
|
if ( !bIntrincic && pile->GetState() == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar* ppVars[1000];
|
||||||
|
CBotStack* pile2 = pile;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
CBotInstr* p = m_parameters;
|
||||||
|
// evaluates the parameters
|
||||||
|
// and the values an the stack
|
||||||
|
// so that it can be interrupted at any time
|
||||||
|
|
||||||
|
if ( p != nullptr) while ( true )
|
||||||
|
{
|
||||||
|
pile2 = pile2->RestoreStack(); // place on the stack for the results
|
||||||
|
if ( pile2 == nullptr ) return;
|
||||||
|
|
||||||
|
if ( pile2->GetState() == 0 )
|
||||||
|
{
|
||||||
|
p->RestoreState(pile2, bMain); // interrupted here?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ppVars[i++] = pile2->GetVar();
|
||||||
|
p = p->GetNext();
|
||||||
|
if ( p == nullptr) break;
|
||||||
|
}
|
||||||
|
ppVars[i] = nullptr;
|
||||||
|
|
||||||
|
// creates a variable for the result
|
||||||
|
// CBotVar* pResult = nullptr; // constructor still void
|
||||||
|
|
||||||
|
pClass->RestoreMethode(m_nMethodeIdent, pClass->GetName(), pThis, ppVars, pile2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_next2b != nullptr )
|
||||||
|
m_next2b->RestoreState(pile, bMain); // other(s) definition(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefClass::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_parameters"] = m_parameters;
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of class instance variable
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* \code
|
||||||
|
* ClassName varname;
|
||||||
|
* ClassName varname();
|
||||||
|
* ClassName varname = new ClassName();
|
||||||
|
* ClassName varname = new ClassName(args);
|
||||||
|
* ClassName varname1(), varname2();
|
||||||
|
* ClassName varname1 = new ClassName(), varname2;
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
class CBotDefClass : public CBotInstr
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBotDefClass();
|
||||||
|
~CBotDefClass();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile Definition of pointer (s) to an object style CPoint A, B ;
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param pClass
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass = nullptr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Declaration of the instance of a class, for example:
|
||||||
|
* CPoint A, B;
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotClassInstr"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Variable to initialise.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! Parameters to be evaluated for the contructor.
|
||||||
|
CBotInstr* m_parameters;
|
||||||
|
//! A value to put, if there is.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
//! Has it parameters.
|
||||||
|
bool m_hasParams;
|
||||||
|
//! Constructor method unique identifier
|
||||||
|
long m_nMethodeIdent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefFloat.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
#include "CBot/CBotInstr/CBotDefArray.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefFloat::CBotDefFloat()
|
||||||
|
{
|
||||||
|
m_var = nullptr;
|
||||||
|
m_expr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefFloat::~CBotDefFloat()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
delete m_expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip)
|
||||||
|
{
|
||||||
|
CBotToken* pp = cont ? nullptr : p;
|
||||||
|
|
||||||
|
if (!cont && !IsOfType(p, ID_FLOAT)) return nullptr;
|
||||||
|
|
||||||
|
CBotDefFloat* inst = static_cast<CBotDefFloat*>(CompileArray(p, pStack, CBotTypFloat));
|
||||||
|
if (inst != nullptr || !pStack->IsOk()) return inst;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||||
|
|
||||||
|
inst = new CBotDefFloat();
|
||||||
|
|
||||||
|
inst->m_expr = nullptr;
|
||||||
|
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
CBotVar* var = nullptr;
|
||||||
|
inst->SetToken(vartoken);
|
||||||
|
|
||||||
|
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypFloat;
|
||||||
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of a variable
|
||||||
|
{
|
||||||
|
pStk->SetStartError(vartoken->GetStart());
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken->GetEnd());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPBRK))
|
||||||
|
{
|
||||||
|
delete inst;
|
||||||
|
p = vartoken;
|
||||||
|
inst = static_cast<CBotDefFloat*>(CBotDefArray::Compile(p, pStk, CBotTypFloat));
|
||||||
|
|
||||||
|
if (!pStk->IsOk() )
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
goto suite; // no assignment, variable already created
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS))
|
||||||
|
{
|
||||||
|
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (pStk->GetType() >= CBotTypBoolean)
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var = CBotVar::Create(*vartoken, CBotTypFloat);
|
||||||
|
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
|
||||||
|
var->SetUniqNum(
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
pStack->AddVar(var);
|
||||||
|
suite:
|
||||||
|
if (IsOfType(p, ID_COMMA))
|
||||||
|
{
|
||||||
|
if (nullptr != ( inst->m_next2b = CBotDefFloat::Compile(p, pStk, true, noskip)))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noskip || IsOfType(p, ID_SEP))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefFloat::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr && !m_expr->Execute(pile)) return false;
|
||||||
|
m_var->Execute(pile);
|
||||||
|
|
||||||
|
if (!pile->SetState(1)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
if ( m_next2b &&
|
||||||
|
!m_next2b->Execute(pile)) return false;
|
||||||
|
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefFloat::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
if (bMain)
|
||||||
|
{
|
||||||
|
pile = pj->RestoreStack(this);
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr) m_expr->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_var->RestoreState(pile, bMain);
|
||||||
|
|
||||||
|
if (m_next2b)
|
||||||
|
m_next2b->RestoreState(pile, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefFloat::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of a float variable - float a, b = 12.4
|
||||||
|
*/
|
||||||
|
class CBotDefFloat : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDefFloat();
|
||||||
|
~CBotDefFloat();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param cont
|
||||||
|
* \param noskip
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes the definition of a real variable.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDefFloat"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Variable to initialise.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! A value to put, if there is.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefInt.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotDefArray.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefInt::CBotDefInt()
|
||||||
|
{
|
||||||
|
m_next = nullptr; // for multiple definitions
|
||||||
|
m_var = nullptr;
|
||||||
|
m_expr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefInt::~CBotDefInt()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
delete m_expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip)
|
||||||
|
{
|
||||||
|
CBotToken* pp = cont ? nullptr : p; // no repetition of the token "int"
|
||||||
|
|
||||||
|
if (!cont && !IsOfType(p, ID_INT)) return nullptr;
|
||||||
|
|
||||||
|
CBotDefInt* inst = static_cast<CBotDefInt*>(CompileArray(p, pStack, CBotTypInt));
|
||||||
|
if (inst != nullptr || !pStack->IsOk()) return inst;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||||
|
|
||||||
|
inst = new CBotDefInt();
|
||||||
|
|
||||||
|
inst->m_expr = nullptr;
|
||||||
|
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
inst->SetToken(vartoken);
|
||||||
|
|
||||||
|
// determines the expression is valid for the item on the left side
|
||||||
|
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypInt;
|
||||||
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_OPBRK))
|
||||||
|
{
|
||||||
|
delete inst; // type is not CBotDefInt
|
||||||
|
p = vartoken; // returns the variable name
|
||||||
|
|
||||||
|
// compiles an array declaration
|
||||||
|
|
||||||
|
CBotInstr* inst2 = CBotDefArray::Compile(p, pStk, CBotTypInt);
|
||||||
|
|
||||||
|
if (!pStk->IsOk() )
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_COMMA)) // several definition chained
|
||||||
|
{
|
||||||
|
if (nullptr != ( inst2->m_next2b = CBotDefInt::Compile(p, pStk, true, noskip))) // compile the next one
|
||||||
|
{
|
||||||
|
return pStack->Return(inst2, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inst = static_cast<CBotDefInt*>(inst2);
|
||||||
|
goto suite; // no assignment, variable already created
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS)) // with an assignment?
|
||||||
|
{
|
||||||
|
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (pStk->GetType() >= CBotTypBoolean) // compatible type ?
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
CBotVar* var = CBotVar::Create(*vartoken, CBotTypInt);// create the variable (evaluated after the 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
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
pStack->AddVar(var); // place it on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_COMMA)) // chained several definitions
|
||||||
|
{
|
||||||
|
if (nullptr != ( inst->m_next2b = CBotDefInt::Compile(p, pStk, true, noskip))) // compile next one
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
suite:
|
||||||
|
if (noskip || IsOfType(p, ID_SEP)) // instruction is completed
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefInt::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this); // essential for SetState()
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr && !m_expr->Execute(pile)) return false; // initial value // interrupted?
|
||||||
|
m_var->Execute(pile); // creates and assign the result
|
||||||
|
|
||||||
|
if (!pile->SetState(1)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
if ( m_next2b &&
|
||||||
|
!m_next2b->Execute(pile)) return false; // other(s) definition(s)
|
||||||
|
|
||||||
|
return pj->Return(pile); // forward below
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefInt::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
if (bMain)
|
||||||
|
{
|
||||||
|
pile = pj->RestoreStack(this);
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr) m_expr->RestoreState(pile, bMain); // initial value // interrupted?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_var->RestoreState(pile, bMain);
|
||||||
|
|
||||||
|
if (m_next2b) m_next2b->RestoreState(pile, bMain); // other(s) definition(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefInt::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of an integer variable - int a, b = 12
|
||||||
|
*/
|
||||||
|
class CBotDefInt : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDefInt();
|
||||||
|
~CBotDefInt();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param cont
|
||||||
|
* \param noskip
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execute the definition of the integer variable.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDefInt"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! The variable to initialize.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! A value to put, if there is.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,168 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefString.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotLeftExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefString::CBotDefString()
|
||||||
|
{
|
||||||
|
m_var = nullptr;
|
||||||
|
m_expr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDefString::~CBotDefString()
|
||||||
|
{
|
||||||
|
delete m_var;
|
||||||
|
delete m_expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDefString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip)
|
||||||
|
{
|
||||||
|
CBotToken* pp = cont ? nullptr : p;
|
||||||
|
|
||||||
|
if (!cont && !IsOfType(p, ID_STRING)) return nullptr;
|
||||||
|
|
||||||
|
CBotDefString* inst = static_cast<CBotDefString*>(CompileArray(p, pStack, CBotTypString));
|
||||||
|
if (inst != nullptr || !pStack->IsOk()) return inst;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||||
|
|
||||||
|
inst = new CBotDefString();
|
||||||
|
|
||||||
|
inst->m_expr = nullptr;
|
||||||
|
|
||||||
|
CBotToken* vartoken = p;
|
||||||
|
inst->SetToken(vartoken);
|
||||||
|
|
||||||
|
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypString;
|
||||||
|
if (pStk->CheckVarLocal(vartoken))
|
||||||
|
{
|
||||||
|
pStk->SetStartError(vartoken->GetStart());
|
||||||
|
pStk->SetError(CBotErrRedefVar, vartoken->GetEnd());
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_ASS))
|
||||||
|
{
|
||||||
|
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
|
||||||
|
{
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
/* if (!pStk->GetTypResult().Eq(CBotTypString)) // type compatible ?
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||||
|
goto error;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create(*vartoken, CBotTypString);
|
||||||
|
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
|
||||||
|
var->SetUniqNum(
|
||||||
|
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
pStack->AddVar(var);
|
||||||
|
|
||||||
|
if (IsOfType(p, ID_COMMA))
|
||||||
|
{
|
||||||
|
if (nullptr != ( inst->m_next2b = CBotDefString::Compile(p, pStk, true, noskip)))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noskip || IsOfType(p, ID_SEP))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDefString::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr && !m_expr->Execute(pile)) return false;
|
||||||
|
m_var->Execute(pile);
|
||||||
|
|
||||||
|
if (!pile->SetState(1)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
if ( m_next2b &&
|
||||||
|
!m_next2b->Execute(pile)) return false;
|
||||||
|
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDefString::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
|
||||||
|
if (bMain)
|
||||||
|
{
|
||||||
|
pile = pj->RestoreStack(this);
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
if ( pile->GetState()==0)
|
||||||
|
{
|
||||||
|
if (m_expr) m_expr->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_var->RestoreState(pile, bMain);
|
||||||
|
|
||||||
|
if (m_next2b)
|
||||||
|
m_next2b->RestoreState(pile, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDefString::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_var"] = m_var;
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Definition of a string variable - string a, b = "text";
|
||||||
|
*/
|
||||||
|
class CBotDefString : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDefString();
|
||||||
|
~CBotDefString();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param cont
|
||||||
|
* \param noskip
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes the definition of the string variable.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDefString"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Variable to initialise.
|
||||||
|
CBotInstr* m_var;
|
||||||
|
//! A value to put, if there is.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDo.h"
|
||||||
|
#include "CBot/CBotInstr/CBotBlock.h"
|
||||||
|
#include "CBot/CBotInstr/CBotCondition.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDo::CBotDo()
|
||||||
|
{
|
||||||
|
m_condition = nullptr;
|
||||||
|
m_block = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotDo::~CBotDo()
|
||||||
|
{
|
||||||
|
delete m_condition; // frees the condition
|
||||||
|
delete m_block; // frees the instruction block
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotDo* inst = new CBotDo(); // creates the object
|
||||||
|
|
||||||
|
CBotToken* pp = p; // preserves at the ^ token (starting position)
|
||||||
|
|
||||||
|
if ( IsOfType( p, TokenTypVar ) &&
|
||||||
|
IsOfType( p, ID_DOTS ) )
|
||||||
|
{
|
||||||
|
inst->m_label = pp->GetString(); // register the name of label
|
||||||
|
}
|
||||||
|
|
||||||
|
inst->SetToken(p);
|
||||||
|
if (!IsOfType(p, ID_DO)) return nullptr; // should never happen
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp); // un petit bout de pile svp
|
||||||
|
|
||||||
|
|
||||||
|
// looking for a statement block after the do
|
||||||
|
IncLvl(inst->m_label);
|
||||||
|
inst->m_block = CBotBlock::CompileBlkOrInst(p, pStk, true );
|
||||||
|
DecLvl();
|
||||||
|
|
||||||
|
if ( pStk->IsOk() )
|
||||||
|
{
|
||||||
|
if (IsOfType(p, ID_WHILE))
|
||||||
|
{
|
||||||
|
if ( nullptr != (inst->m_condition = CBotCondition::Compile(p, pStk )) )
|
||||||
|
{
|
||||||
|
// the condition exists
|
||||||
|
if (IsOfType(p, ID_SEP))
|
||||||
|
{
|
||||||
|
return pStack->Return(inst, pStk); // return an object to the application
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotErrNoTerminator, p->GetStart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotErrNoWhile, p->GetStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
delete inst; // error, frees up
|
||||||
|
return pStack->Return(nullptr, pStk); // no object, the error is on the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotDo :: Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this); // adds an item to the stack
|
||||||
|
// or find in case of recovery
|
||||||
|
// if ( pile == EOX ) return true;
|
||||||
|
|
||||||
|
if ( pile->IfStep() ) return false;
|
||||||
|
|
||||||
|
while( true ) switch( pile->GetState() ) // executes the loop
|
||||||
|
{ // there are two possible states (depending on recovery)
|
||||||
|
case 0:
|
||||||
|
// evaluates the associated statement block
|
||||||
|
if (m_block != nullptr &&
|
||||||
|
!m_block->Execute(pile) )
|
||||||
|
{
|
||||||
|
if (pile->IfContinue(1, m_label)) continue; // if continued, will return to test
|
||||||
|
return pj->BreakReturn(pile, m_label); // sends the results and releases the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
// terminates if there is an error
|
||||||
|
if ( !pile->IsOk() )
|
||||||
|
{
|
||||||
|
return pj->Return(pile); // sends the results and releases the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pile->SetState(1)) return false; // ready for further
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// evaluates the condition
|
||||||
|
if ( !m_condition->Execute(pile) ) return false; // interrupted here ?
|
||||||
|
|
||||||
|
// the result of the condition is on the stack
|
||||||
|
|
||||||
|
// terminates if an error or if the condition is false
|
||||||
|
if ( !pile->IsOk() || pile->GetVal() != true )
|
||||||
|
{
|
||||||
|
return pj->Return(pile); // sends the results and releases the stack
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns to instruction block to start
|
||||||
|
if (!pile->SetState(0, 0)) return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if ( !bMain ) return;
|
||||||
|
|
||||||
|
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||||
|
if ( pile == nullptr ) return;
|
||||||
|
|
||||||
|
switch( pile->GetState() )
|
||||||
|
{ // there are two possible states (depending on recovery)
|
||||||
|
case 0:
|
||||||
|
// restores the assosiated statement's block
|
||||||
|
if (m_block != nullptr ) m_block->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// restores the condition
|
||||||
|
m_condition->RestoreState(pile, bMain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotDo::GetDebugData()
|
||||||
|
{
|
||||||
|
return !m_label.empty() ? "m_label = "+m_label : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotDo::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_block"] = m_block;
|
||||||
|
links["m_condition"] = m_condition;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 do {...} while (...) structure
|
||||||
|
*/
|
||||||
|
class CBotDo : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotDo();
|
||||||
|
~CBotDo();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile Compile the instruction "do".
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotDo"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Instruction
|
||||||
|
CBotInstr* m_block;
|
||||||
|
//! Conditions
|
||||||
|
CBotInstr* m_condition;
|
||||||
|
//! A label if there is
|
||||||
|
std::string m_label;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotEmpty.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotEmpty::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotVar* pVar = CBotVar::Create("", CBotTypInt);
|
||||||
|
pVar->SetValInt(-1);
|
||||||
|
pj->SetVar(pVar);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotEmpty::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Constant -1 of type int
|
||||||
|
* \todo Whaaaat? What is this even doing here? ~krzys_h
|
||||||
|
*/
|
||||||
|
class CBotEmpty : public CBotInstr
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Execute Special case for empty indexes.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotEmpty"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprLitBool.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitBool::CBotExprLitBool()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitBool::~CBotExprLitBool()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprLitBool::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
CBotExprLitBool* inst = nullptr;
|
||||||
|
|
||||||
|
if ( p->GetType() == ID_TRUE ||
|
||||||
|
p->GetType() == ID_FALSE )
|
||||||
|
{
|
||||||
|
inst = new CBotExprLitBool();
|
||||||
|
inst->SetToken(p); // stores the operation false or true
|
||||||
|
p = p->GetNext();
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypBoolean);
|
||||||
|
pStk->SetVar(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprLitBool::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypBoolean);
|
||||||
|
|
||||||
|
if (GetTokenType() == ID_TRUE) var->SetValInt(1);
|
||||||
|
else var->SetValInt(0);
|
||||||
|
|
||||||
|
pile->SetVar(var); // put on the stack
|
||||||
|
return pj->Return(pile); // forwards below
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprLitBool::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (bMain) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 boolean literal - true/false
|
||||||
|
*/
|
||||||
|
class CBotExprLitBool : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprLitBool();
|
||||||
|
~CBotExprLitBool();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes, returns true or false.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprLitBool"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprLitNan.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNan::CBotExprLitNan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNan::~CBotExprLitNan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprLitNan::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypInt);
|
||||||
|
|
||||||
|
var->SetInit(CBotVar::InitType::IS_NAN); // nan
|
||||||
|
pile->SetVar(var); // put on the stack
|
||||||
|
return pj->Return(pile); // forward below
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprLitNan::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (bMain) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 The "nan" constant
|
||||||
|
*/
|
||||||
|
class CBotExprLitNan : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprLitNan();
|
||||||
|
~CBotExprLitNan();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes, returns null pointer.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprLitNan"; }
|
||||||
|
virtual std::string GetDebugData() override { return "nan"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprLitNull.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNull::CBotExprLitNull()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNull::~CBotExprLitNull()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprLitNull::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypNullPointer);
|
||||||
|
|
||||||
|
var->SetInit(CBotVar::InitType::DEF); // null pointer valid
|
||||||
|
pile->SetVar(var); // place on the stack
|
||||||
|
return pj->Return(pile); // forwards below
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprLitNull::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (bMain) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 The "null" constant
|
||||||
|
*/
|
||||||
|
class CBotExprLitNull : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprLitNull();
|
||||||
|
~CBotExprLitNull();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Executes, returns an empty pointer.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprLitNull"; }
|
||||||
|
virtual std::string GetDebugData() override { return "null"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprLitNum.h"
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotUtils.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNum::CBotExprLitNum()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitNum::~CBotExprLitNum()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprLitNum::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
|
||||||
|
CBotExprLitNum* inst = new CBotExprLitNum();
|
||||||
|
|
||||||
|
inst->SetToken(p);
|
||||||
|
std::string s = p->GetString();
|
||||||
|
|
||||||
|
inst->m_numtype = CBotTypInt;
|
||||||
|
if (p->GetType() == TokenTypDef)
|
||||||
|
{
|
||||||
|
inst->m_valint = p->GetKeywordId();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s.find('.') != std::string::npos || ( s.find('x') == std::string::npos && ( s.find_first_of("eE") != std::string::npos ) ))
|
||||||
|
{
|
||||||
|
inst->m_numtype = CBotTypFloat;
|
||||||
|
inst->m_valfloat = GetNumFloat(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inst->m_valint = GetNumInt(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pStk->NextToken(p))
|
||||||
|
{
|
||||||
|
CBotVar* var = CBotVar::Create("", inst->m_numtype);
|
||||||
|
pStk->SetVar(var);
|
||||||
|
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprLitNum::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create("", m_numtype);
|
||||||
|
|
||||||
|
std::string nombre ;
|
||||||
|
if (m_token.GetType() == TokenTypDef)
|
||||||
|
{
|
||||||
|
nombre = m_token.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_numtype)
|
||||||
|
{
|
||||||
|
case CBotTypShort:
|
||||||
|
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
|
||||||
|
|
||||||
|
return pj->Return(pile); // it's ok
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprLitNum::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (bMain) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotExprLitNum::GetDebugData()
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "(" << (m_numtype == CBotTypFloat ? "float" : "int") << ") " << (m_numtype == CBotTypFloat ? m_valfloat : m_valint);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 number literal - 5, 1, 2.5, 3.75, etc. or a predefined numerical constant (see CBotToken::DefineNum())
|
||||||
|
*
|
||||||
|
* Can be of type ::CBotTypInt or ::CBotTypFloat
|
||||||
|
*/
|
||||||
|
class CBotExprLitNum : public CBotInstr
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBotExprLitNum();
|
||||||
|
~CBotExprLitNum();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execute, returns the corresponding number.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprLitNum"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! The type of number.
|
||||||
|
CBotType m_numtype;
|
||||||
|
//! Value for an int.
|
||||||
|
long m_valint;
|
||||||
|
//! Value for a float.
|
||||||
|
float m_valfloat;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprLitString.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitString::CBotExprLitString()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprLitString::~CBotExprLitString()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprLitString::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
|
||||||
|
CBotExprLitString* inst = new CBotExprLitString();
|
||||||
|
|
||||||
|
inst->SetToken(p);
|
||||||
|
p = p->GetNext();
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypString);
|
||||||
|
pStk->SetVar(var);
|
||||||
|
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprLitString::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->IfStep()) return false;
|
||||||
|
|
||||||
|
CBotVar* var = CBotVar::Create("", CBotTypString);
|
||||||
|
|
||||||
|
std::string chaine = m_token.GetString();
|
||||||
|
chaine = chaine.substr(1, chaine.length()-2); // removes the quotes
|
||||||
|
|
||||||
|
var->SetValString(chaine); // value of the number
|
||||||
|
|
||||||
|
pile->SetVar(var); // put on the stack
|
||||||
|
|
||||||
|
return pj->Return(pile);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprLitString::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (bMain) pj->RestoreStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotExprLitString::GetDebugData()
|
||||||
|
{
|
||||||
|
return m_token.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 string literal - "Some text"
|
||||||
|
*/
|
||||||
|
class CBotExprLitString : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprLitString();
|
||||||
|
~CBotExprLitString();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execute, returns the corresponding string.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprLitString"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotExprUnaire.h"
|
||||||
|
#include "CBot/CBotInstr/CBotParExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprUnaire::CBotExprUnaire()
|
||||||
|
{
|
||||||
|
m_expr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprUnaire::~CBotExprUnaire()
|
||||||
|
{
|
||||||
|
delete m_expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
int op = p->GetType();
|
||||||
|
CBotToken* pp = p;
|
||||||
|
if (!IsOfTypeList( p, ID_ADD, ID_SUB, ID_LOG_NOT, ID_TXT_NOT, ID_NOT, 0 )) return nullptr;
|
||||||
|
|
||||||
|
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||||
|
|
||||||
|
CBotExprUnaire* inst = new CBotExprUnaire();
|
||||||
|
inst->SetToken(pp);
|
||||||
|
|
||||||
|
if (nullptr != (inst->m_expr = CBotParExpr::Compile(p, pStk )))
|
||||||
|
{
|
||||||
|
if (op == ID_ADD && pStk->GetType() < CBotTypBoolean) // only with the number
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
if (op == ID_SUB && pStk->GetType() < CBotTypBoolean) // only with the numer
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
if (op == ID_NOT && pStk->GetType() < CBotTypFloat) // only with an integer
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
if (op == ID_LOG_NOT && pStk->GetTypResult().Eq(CBotTypBoolean))// only with boolean
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
if (op == ID_TXT_NOT && pStk->GetTypResult().Eq(CBotTypBoolean))// only with boolean
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
|
||||||
|
pStk->SetError(CBotErrBadType1, &inst->m_token);
|
||||||
|
}
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
// executes unary expression
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprUnaire::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (pile->GetState() == 0)
|
||||||
|
{
|
||||||
|
if (!m_expr->Execute(pile)) return false; // interrupted ?
|
||||||
|
pile->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotStack* pile2 = pile->AddStack();
|
||||||
|
if (pile2->IfStep()) return false;
|
||||||
|
|
||||||
|
CBotVar* var = pile->GetVar(); // get the result on the stack
|
||||||
|
|
||||||
|
switch (GetTokenType())
|
||||||
|
{
|
||||||
|
case ID_ADD:
|
||||||
|
break;
|
||||||
|
case ID_SUB:
|
||||||
|
var->Neg(); // change the sign
|
||||||
|
break;
|
||||||
|
case ID_NOT:
|
||||||
|
case ID_LOG_NOT:
|
||||||
|
case ID_TXT_NOT:
|
||||||
|
var->Not();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return pj->Return(pile); // forwards below
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprUnaire::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (!bMain) return;
|
||||||
|
|
||||||
|
CBotStack* pile = pj->RestoreStack(this);
|
||||||
|
if ( pile == nullptr) return;
|
||||||
|
|
||||||
|
if (pile->GetState() == 0)
|
||||||
|
{
|
||||||
|
m_expr->RestoreState(pile, bMain); // interrupted here!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, CBotInstr*> CBotExprUnaire::GetDebugLinks()
|
||||||
|
{
|
||||||
|
auto links = CBotInstr::GetDebugLinks();
|
||||||
|
links["m_expr"] = m_expr;
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 Unary expression - +a, -a, !a, ~a, not a
|
||||||
|
*/
|
||||||
|
class CBotExprUnaire : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprUnaire();
|
||||||
|
~CBotExprUnaire();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pStack) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprUnaire"; }
|
||||||
|
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Expression to be evaluated.
|
||||||
|
CBotInstr* m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,316 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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 <sstream>
|
||||||
|
#include "CBot/CBotInstr/CBotExprVar.h"
|
||||||
|
#include "CBot/CBotInstr/CBotInstrMethode.h"
|
||||||
|
#include "CBot/CBotInstr/CBotExpression.h"
|
||||||
|
#include "CBot/CBotInstr/CBotIndexExpr.h"
|
||||||
|
#include "CBot/CBotInstr/CBotFieldExpr.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotStack.h"
|
||||||
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotVar/CBotVarArray.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprVar::CBotExprVar()
|
||||||
|
{
|
||||||
|
m_nIdent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotExprVar::~CBotExprVar()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::ProtectionLevel privat)
|
||||||
|
{
|
||||||
|
// CBotToken* pDebut = p;
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
|
||||||
|
pStk->SetStartError(p->GetStart());
|
||||||
|
|
||||||
|
// is it a variable?
|
||||||
|
if (p->GetType() == TokenTypVar)
|
||||||
|
{
|
||||||
|
CBotInstr* inst = new CBotExprVar(); // create the object
|
||||||
|
|
||||||
|
inst->SetToken(p);
|
||||||
|
|
||||||
|
CBotVar* var;
|
||||||
|
|
||||||
|
if (nullptr != (var = pStk->FindVar(p))) // seek if known variable
|
||||||
|
{
|
||||||
|
int ident = var->GetUniqNum();
|
||||||
|
(static_cast<CBotExprVar*>(inst))->m_nIdent = ident; // identifies variable by its number
|
||||||
|
|
||||||
|
if (ident > 0 && ident < 9000)
|
||||||
|
{
|
||||||
|
if ( var->IsPrivate(privat) &&
|
||||||
|
!pStk->GetProgram()->m_bCompileClass)
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrPrivate, p);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is an element of the current class
|
||||||
|
// ads the equivalent of this. before
|
||||||
|
CBotToken token("this");
|
||||||
|
inst->SetToken(&token);
|
||||||
|
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // identificator for this
|
||||||
|
|
||||||
|
CBotFieldExpr* i = new CBotFieldExpr(); // new element
|
||||||
|
i->SetToken(p); // keeps the name of the token
|
||||||
|
i->SetUniqNum(ident);
|
||||||
|
inst->AddNext3(i); // added after
|
||||||
|
}
|
||||||
|
|
||||||
|
p = p->GetNext(); // next token
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (var->GetType() == CBotTypArrayPointer)
|
||||||
|
{
|
||||||
|
if (IsOfType( p, ID_OPBRK )) // check if there is an aindex
|
||||||
|
{
|
||||||
|
CBotIndexExpr* i = new CBotIndexExpr();
|
||||||
|
i->m_expr = CBotExpression::Compile(p, pStk); // compile the formula
|
||||||
|
inst->AddNext3(i); // add to the chain
|
||||||
|
|
||||||
|
var = (static_cast<CBotVarArray*>(var))->GetItem(0,true); // gets the component [0]
|
||||||
|
|
||||||
|
if (i->m_expr == nullptr)
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrBadIndex, p->GetStart());
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (!pStk->IsOk() || !IsOfType( p, ID_CLBRK ))
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrCloseIndex, p->GetStart());
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (var->GetType(CBotVar::GetTypeMode::CLASS_AS_POINTER) == CBotTypPointer) // for classes
|
||||||
|
{
|
||||||
|
if (IsOfType(p, ID_DOT))
|
||||||
|
{
|
||||||
|
CBotToken* pp = p;
|
||||||
|
|
||||||
|
if (p->GetType() == TokenTypVar) // must be a name
|
||||||
|
{
|
||||||
|
if (p->GetNext()->GetType() == ID_OPENPAR) // a method call?
|
||||||
|
{
|
||||||
|
CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var);
|
||||||
|
if (!pStk->IsOk()) goto err;
|
||||||
|
inst->AddNext3(i); // added after
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CBotFieldExpr* i = new CBotFieldExpr(); // new element
|
||||||
|
i->SetToken(pp); // keeps the name of the token
|
||||||
|
inst->AddNext3(i); // add after
|
||||||
|
var = var->GetItem(p->GetString()); // get item correspondent
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
i->SetUniqNum(var->GetUniqNum());
|
||||||
|
if ( var->IsPrivate() &&
|
||||||
|
!pStk->GetProgram()->m_bCompileClass)
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrPrivate, pp);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
p = p->GetNext(); // skips the name
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotErrUndefItem, p);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotErrUndefClass, p->GetStart());
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStk->SetCopyVar(var); // place the copy of the variable on the stack (for type)
|
||||||
|
if (pStk->IsOk()) return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotErrUndefVar, p);
|
||||||
|
err:
|
||||||
|
delete inst;
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
{
|
||||||
|
CBotToken* pp = p;
|
||||||
|
CBotCStack* pStk = pStack->TokenStack();
|
||||||
|
|
||||||
|
pStk->SetStartError(pp->GetStart());
|
||||||
|
|
||||||
|
// is it a variable ?
|
||||||
|
if (pp->GetType() == TokenTypVar)
|
||||||
|
{
|
||||||
|
CBotToken pthis("this");
|
||||||
|
CBotVar* var = pStk->FindVar(pthis);
|
||||||
|
if (var == nullptr) return pStack->Return(nullptr, pStk);
|
||||||
|
|
||||||
|
CBotInstr* inst = new CBotExprVar();
|
||||||
|
|
||||||
|
// this is an element of the current class
|
||||||
|
// adds the equivalent of this. before
|
||||||
|
|
||||||
|
inst->SetToken(&pthis);
|
||||||
|
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // ident for this
|
||||||
|
|
||||||
|
CBotToken* pp = p;
|
||||||
|
|
||||||
|
if (pp->GetType() == TokenTypVar)
|
||||||
|
{
|
||||||
|
if (pp->GetNext()->GetType() == ID_OPENPAR) // a method call?
|
||||||
|
{
|
||||||
|
CBotInstr* i = CBotInstrMethode::Compile(pp, pStk, var);
|
||||||
|
if (pStk->IsOk())
|
||||||
|
{
|
||||||
|
inst->AddNext3(i); // add after
|
||||||
|
p = pp; // previous instruction
|
||||||
|
return pStack->Return(inst, pStk);
|
||||||
|
}
|
||||||
|
pStk->SetError(CBotNoErr, 0); // the error is not adressed here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete inst;
|
||||||
|
}
|
||||||
|
return pStack->Return(nullptr, pStk);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprVar::Execute(CBotStack* &pj)
|
||||||
|
{
|
||||||
|
CBotVar* pVar = nullptr;
|
||||||
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
|
CBotStack* pile1 = pile;
|
||||||
|
|
||||||
|
if (pile1->GetState() == 0)
|
||||||
|
{
|
||||||
|
if (!ExecuteVar(pVar, pile, nullptr, true)) return false; // Get the variable fields and indexes according
|
||||||
|
|
||||||
|
if (pVar) pile1->SetCopyVar(pVar); // place a copy on the stack
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pj->Return(pile1);
|
||||||
|
}
|
||||||
|
pile1->IncState();
|
||||||
|
}
|
||||||
|
|
||||||
|
pVar = pile1->GetVar();
|
||||||
|
|
||||||
|
if (pVar == nullptr)
|
||||||
|
{
|
||||||
|
return pj->Return(pile1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pVar->IsUndefined())
|
||||||
|
{
|
||||||
|
CBotToken* pt = &m_token;
|
||||||
|
while (pt->GetNext() != nullptr) pt = pt->GetNext();
|
||||||
|
pile1->SetError(CBotErrNotInit, pt);
|
||||||
|
return pj->Return(pile1);
|
||||||
|
}
|
||||||
|
return pj->Return(pile1); // operation completed
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprVar::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
if (!bMain) return;
|
||||||
|
|
||||||
|
CBotStack* pile = pj->RestoreStack(this);
|
||||||
|
if (pile == nullptr) return;
|
||||||
|
|
||||||
|
CBotStack* pile1 = pile;
|
||||||
|
|
||||||
|
if (pile1->GetState() == 0)
|
||||||
|
{
|
||||||
|
RestoreStateVar(pile, bMain); // retrieves the variable fields and indexes according
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep)
|
||||||
|
{
|
||||||
|
CBotStack* pile = pj;
|
||||||
|
pj = pj->AddStack(this);
|
||||||
|
|
||||||
|
if (bStep && m_nIdent>0 && pj->IfStep()) return false;
|
||||||
|
|
||||||
|
pVar = pj->FindVar(m_nIdent, true); // tries with the variable update if necessary
|
||||||
|
if (pVar == nullptr)
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
//pj->SetError(static_cast<CBotError>(1), &m_token); // TODO: yeah, don't care that this exception doesn't exist ~krzys_h
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( m_next3 != nullptr &&
|
||||||
|
!m_next3->ExecuteVar(pVar, pj, &m_token, bStep, false) )
|
||||||
|
return false; // field of an instance, table, methode
|
||||||
|
|
||||||
|
return pile->ReturnKeep(pj); // does not put on stack but get the result if a method was called
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotExprVar::RestoreStateVar(CBotStack* &pj, bool bMain)
|
||||||
|
{
|
||||||
|
pj = pj->RestoreStack(this);
|
||||||
|
if (pj == nullptr) return;
|
||||||
|
|
||||||
|
if (m_next3 != nullptr)
|
||||||
|
m_next3->RestoreStateVar(pj, bMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CBotExprVar::GetDebugData()
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << m_token.GetString() << std::endl;
|
||||||
|
//ss << "VarID = " << m_nIdent;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CBot
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2016, 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/CBotDefines.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotInstr/CBotInstr.h"
|
||||||
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
namespace CBot
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Expression representing a variable name
|
||||||
|
*
|
||||||
|
* Verifies that variable is known during compilation
|
||||||
|
* Verifies taht variable is initialized during execution
|
||||||
|
*/
|
||||||
|
class CBotExprVar : public CBotInstr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBotExprVar();
|
||||||
|
~CBotExprVar();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compile
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \param privat
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* Compile(CBotToken*& p, CBotCStack* pStack,
|
||||||
|
CBotVar::ProtectionLevel privat = CBotVar::ProtectionLevel::Protected);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CompileMethode
|
||||||
|
* \param p
|
||||||
|
* \param pStack
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Execute Execute, making the value of a variable.
|
||||||
|
* \param pj
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool Execute(CBotStack* &pj) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreState
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreState(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ExecuteVar Fetch a variable at runtime.
|
||||||
|
* \param pVar
|
||||||
|
* \param pile
|
||||||
|
* \param prevToken
|
||||||
|
* \param bStep
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief RestoreStateVar Fetch variable at runtime.
|
||||||
|
* \param pj
|
||||||
|
* \param bMain
|
||||||
|
*/
|
||||||
|
void RestoreStateVar(CBotStack* &pj, bool bMain) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const std::string GetDebugName() override { return "CBotExprVar"; }
|
||||||
|
virtual std::string GetDebugData() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
long m_nIdent;
|
||||||
|
friend class CBotPostIncExpr;
|
||||||
|
friend class CBotPreIncExpr;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CBot
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue