commit
7c2e955e15
|
@ -1,10 +1,3 @@
|
|||
# Ignore the documentation folder
|
||||
/doc
|
||||
|
||||
# Ignore local data
|
||||
/colobot.ini
|
||||
/savegame
|
||||
|
||||
# Ignore the CMake build files
|
||||
CMakeFiles
|
||||
CMakeCache.txt
|
||||
|
@ -13,9 +6,21 @@ Makefile
|
|||
/install_manifest.txt
|
||||
/Testing
|
||||
/CTestTestfile.cmake
|
||||
/src/CBot/tests/CBot_console/bin/
|
||||
|
||||
# Ignore the generated documentation
|
||||
/doc
|
||||
/Doxyfile
|
||||
|
||||
# Ignore targets
|
||||
/colobot
|
||||
|
||||
# Ignore local data
|
||||
/colobot.ini
|
||||
/savegame
|
||||
|
||||
# Standard build directory
|
||||
/build
|
||||
|
||||
# Ignore KDevelop files
|
||||
.kdev4
|
||||
*.kdev4
|
||||
*.flv
|
||||
*.mp4
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ language: cpp
|
|||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
script: mkdir build; cd build; cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON && make all doc test && DESTDIR=. make install
|
||||
script: mkdir build; cd build; cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DOPENAL_SOUND=0 -DTESTS=1 && make all doc test && DESTDIR=. make install
|
||||
before_install:
|
||||
- git submodule update --init --recursive
|
||||
- sudo add-apt-repository ppa:mapnik/boost -y
|
||||
|
|
129
CMakeLists.txt
129
CMakeLists.txt
|
@ -15,8 +15,10 @@ set(COLOBOT_VERSION_MAJOR 0)
|
|||
set(COLOBOT_VERSION_MINOR 1)
|
||||
set(COLOBOT_VERSION_REVISION 0)
|
||||
|
||||
# Comment out when releasing
|
||||
set(COLOBOT_VERSION_UNRELEASED "~pre-alpha")
|
||||
# Used on official releases
|
||||
set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
|
||||
# Used on unreleased, development builds
|
||||
#set(COLOBOT_VERSION_UNRELEASED "+alpha")
|
||||
|
||||
# Append git characteristics to version
|
||||
if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
|
@ -30,21 +32,20 @@ if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|||
set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
|
||||
endif()
|
||||
|
||||
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}")
|
||||
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}${COLOBOT_VERSION_RELEASE_CODENAME}")
|
||||
message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERSION_FULL})")
|
||||
|
||||
# Include cmake directory with some additional scripts
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
##
|
||||
# Build options
|
||||
##
|
||||
|
||||
# Global build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif()
|
||||
# Build targets should be placed in the root build directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Include cmake directory with some additional scripts
|
||||
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
# Compiler detection
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
|
@ -83,8 +84,14 @@ set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
|
|||
# Asserts can be enabled/disabled regardless of build type
|
||||
option(ASSERTS "Enable assert()s" ON)
|
||||
|
||||
# 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)
|
||||
|
||||
# Building tests can be enabled/disabled
|
||||
option(TESTS "Enable tests" ON)
|
||||
option(TESTS "Build tests" OFF)
|
||||
|
||||
# Building tool programs can be enabled/disabled
|
||||
option(TOOLS "Build tool programs" OFF)
|
||||
|
||||
# CBot can also be a static library
|
||||
option(CBOT_STATIC "Build CBot as static libary" OFF)
|
||||
|
@ -95,8 +102,26 @@ option(DESKTOP "Generate desktop files, manpages, etc" ON)
|
|||
# Doxygen docs are optional for installation
|
||||
option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
||||
|
||||
# Build openal sound support
|
||||
option(OPENAL_SOUND "Build openal sound support" OFF)
|
||||
# Build OpenAL sound support
|
||||
option(OPENAL_SOUND "Build OpenAL sound support" ON)
|
||||
|
||||
# Change to false in case static boost libraries are not available
|
||||
option(BOOST_STATIC "Link with static boost libraries" OFF)
|
||||
|
||||
# This is useful on Windows, if linking against standard GLEW dll fails
|
||||
option(GLEW_STATIC "Link statically with GLEW" OFF)
|
||||
|
||||
|
||||
# Default build type if not given is debug
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Build type not specified - assuming debug")
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif()
|
||||
|
||||
# Warn about development build
|
||||
if(DEV_BUILD)
|
||||
message("Building with development extensions")
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
|
@ -110,21 +135,18 @@ find_package(SDL_ttf 2.0 REQUIRED)
|
|||
find_package(PNG 1.2 REQUIRED)
|
||||
find_package(Gettext REQUIRED)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
set(Boost_USE_STATIC_LIBS ${BOOST_STATIC})
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
|
||||
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
|
||||
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
|
||||
|
||||
# This is useful on Windows, if linking against standard GLEW dll fails
|
||||
option(GLEW_STATIC "Link statically with GLEW" OFF)
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
if (${OPENAL_SOUND})
|
||||
if (OPENAL_SOUND)
|
||||
find_package(OpenAL REQUIRED)
|
||||
include("${colobot_SOURCE_DIR}/cmake/FindLibSndFile.cmake")
|
||||
find_package(LibSndFile REQUIRED)
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -132,11 +154,11 @@ endif()
|
|||
# Platform detection and some related checks
|
||||
##
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
set(PLATFORM_WINDOWS 1)
|
||||
set(PLATFORM_LINUX 0)
|
||||
set(PLATFORM_OTHER 0)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(PLATFORM_WINDOWS 0)
|
||||
set(PLATFORM_LINUX 1)
|
||||
set(PLATFORM_OTHER 0)
|
||||
|
@ -146,11 +168,11 @@ else()
|
|||
set(PLATFORM_OTHER 1)
|
||||
endif()
|
||||
|
||||
if(NOT ${ASSERTS})
|
||||
if(NOT ASSERTS)
|
||||
add_definitions(-DNDEBUG)
|
||||
endif()
|
||||
|
||||
if(${TESTS})
|
||||
if(TESTS)
|
||||
add_definitions(-DTESTS -DTEST_VIRTUAL=virtual)
|
||||
else()
|
||||
add_definitions(-DTEST_VIRTUAL=)
|
||||
|
@ -172,15 +194,29 @@ include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
|
|||
##
|
||||
# Summary of detected things
|
||||
##
|
||||
if (${PLATFORM_WINDOWS})
|
||||
if (PLATFORM_WINDOWS)
|
||||
message(STATUS "Build for Windows system")
|
||||
elseif(${PLATFORM_LINUX})
|
||||
elseif(PLATFORM_LINUX)
|
||||
message(STATUS "Build for Linux system")
|
||||
else()
|
||||
message(STATUS "Build for other system")
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
# Clipboard support
|
||||
##
|
||||
set(CLIPBOARD_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/clipboard/include)
|
||||
add_subdirectory(lib/clipboard)
|
||||
|
||||
|
||||
##
|
||||
# Localename
|
||||
##
|
||||
set(LOCALENAME_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/localename)
|
||||
add_subdirectory(lib/localename)
|
||||
|
||||
|
||||
##
|
||||
# Doxygen docs
|
||||
##
|
||||
|
@ -200,7 +236,7 @@ endif()
|
|||
# Targets
|
||||
##
|
||||
|
||||
if(${TESTS})
|
||||
if(TESTS)
|
||||
# Google Test library
|
||||
find_path(GTEST_SRC_DIR NAMES src/gtest.cc src/gtest-all.cc PATHS /usr/src PATH_SUFFIXES gtest)
|
||||
find_path(GTEST_INCLUDE_DIR gtest/gtest.h PATHS /usr/include)
|
||||
|
@ -212,7 +248,7 @@ if(${TESTS})
|
|||
set(GTEST_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gtest/include)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${GTEST_SRC_DIR} bin/gtest)
|
||||
add_subdirectory(${GTEST_SRC_DIR} lib/gtest)
|
||||
|
||||
# Google Mock library
|
||||
find_path(GMOCK_SRC_DIR NAMES src/gmock.cc src/gmock-all.cc PATHS /usr/src PATH_SUFFIXES gmock)
|
||||
|
@ -227,23 +263,32 @@ if(${TESTS})
|
|||
message(STATUS "Using bundled gmock library")
|
||||
set(GMOCK_SRC_DIR ${colobot_SOURCE_DIR}/lib/gmock)
|
||||
set(GMOCK_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gmock/include)
|
||||
add_subdirectory(${GMOCK_SRC_DIR} bin/gmock)
|
||||
add_subdirectory(${GMOCK_SRC_DIR} lib/gmock)
|
||||
endif()
|
||||
|
||||
|
||||
# Tests targets
|
||||
enable_testing()
|
||||
add_subdirectory(test bin/test)
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
# Installation paths defined before compiling sources
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot translations directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
|
||||
if(PLATFORM_WINDOWS)
|
||||
if(MXE)
|
||||
# We need to use STRING because PATH doesn't accept relative paths
|
||||
set(COLOBOT_INSTALL_BIN_DIR ./ CACHE STRING "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ./ CACHE STRING "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ./data CACHE STRING "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ./lang CACHE STRING "Colobot translations directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ./doc CACHE STRING "Colobot documentation directory")
|
||||
else()
|
||||
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
|
||||
endif()
|
||||
else()
|
||||
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/games CACHE PATH "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/colobot CACHE PATH "Colobot libraries directory")
|
||||
|
@ -253,7 +298,17 @@ else()
|
|||
endif()
|
||||
|
||||
# Subdirectory with sources
|
||||
add_subdirectory(src bin)
|
||||
add_subdirectory(src)
|
||||
|
||||
add_subdirectory(po)
|
||||
|
||||
if(DESKTOP)
|
||||
if(PLATFORM_WINDOWS)
|
||||
message("Desktop files ignored on Windows")
|
||||
else()
|
||||
add_subdirectory(desktop)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -29,6 +29,7 @@ To cross-compile Colobot using MXE:
|
|||
* check-requirements
|
||||
* expat
|
||||
* flac
|
||||
* flac
|
||||
* freetype
|
||||
* gcc
|
||||
* gcc-gmp
|
||||
|
@ -39,24 +40,21 @@ To cross-compile Colobot using MXE:
|
|||
* jpeg
|
||||
* libiconv
|
||||
* libpng
|
||||
* libsndfile
|
||||
* libtool
|
||||
* mingwrt
|
||||
* ogg
|
||||
* openal
|
||||
* portaudio
|
||||
* sdl
|
||||
* sdl_image
|
||||
* sdl_ttf
|
||||
* tiff
|
||||
* vorbis
|
||||
* w32api
|
||||
* xz
|
||||
* zlib
|
||||
|
||||
For optional audio support you'll need also:
|
||||
* openal
|
||||
* libsndfile
|
||||
* ogg
|
||||
* vorbis
|
||||
* flac
|
||||
|
||||
4. Now `cd` to directory with colobot sources. 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`
|
||||
|
@ -68,4 +66,4 @@ To cross-compile Colobot using MXE:
|
|||
5. `make` should now compile the game with the resulting exe in `bin/colobot.exe`.
|
||||
The exe is linked against all libraries *statically*, so there are no dependencies
|
||||
on external DLLs. However, the resulting binary will be huge with all these libraries,
|
||||
so you might want to do:`strip bin/colobot.exe`.
|
||||
so you might want to do: `strip bin/colobot.exe`.
|
|
@ -6,8 +6,9 @@ Colobot source files can be downloaded from Github repository (https://github.co
|
|||
the repository as a ZIP archive, or, clone the repository using git or a GUI frontent for git.
|
||||
|
||||
Make sure that once you download/clone the repository, you have the neeeded data files in `data/` subdirectory.These files
|
||||
are provided as git submodule, hosted at a separate Github repository (https://github.com/colobot/colobot-data). If you
|
||||
don't have them, download the repository and unpack its content into `data/`.
|
||||
are provided as git submodule, hosted at a separate Github repository (https://github.com/colobot/colobot-data).
|
||||
If you don't have them, you can either download the repository manually and unpack its content into `data/` or,
|
||||
if you're working with git cloned repository, `git submodule update --init` will download the data submodule repository.
|
||||
|
||||
|
||||
## Compiling on Windows
|
||||
|
@ -24,18 +25,19 @@ When installing, select **all** possible packages in the installer.
|
|||
|
||||
Next, download the development package available at Colobot site (http://colobot.info/) and unpack the files
|
||||
from the archive to MinGW directory. This should provide a working environment, including CMake and
|
||||
all necessary packages.
|
||||
all necessary packages. However, make sure you get the right package. There are slight changes between GCC 4.6 and 4.7,
|
||||
especially with boost library which will result in build failure or error in runtime.
|
||||
|
||||
To compile Colobot, `cd` to directory with sources and run:
|
||||
$ cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DOPENAL_SOUND=1 .
|
||||
$ cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release .
|
||||
and then:
|
||||
$ make
|
||||
|
||||
Everything should compile just fine. If you see any errors, it most likely means missing libraries or invalid installation.
|
||||
Warnings may occur, but are mostly harmless.
|
||||
|
||||
You'll get the binary in `bin/colobot.exe`, which you can run directly, pointing it to the data directory:
|
||||
$ bin/colobot.exe -datadir ./data
|
||||
You'll get the binary `colobot.exe`, which you can run directly, pointing it to the data directory:
|
||||
$ colobot.exe -datadir ./data
|
||||
|
||||
You can also install Colobot in your system using
|
||||
$ make install
|
||||
|
@ -49,7 +51,7 @@ See also "Hints and notes" below on some useful advice.
|
|||
|
||||
MXE (http://mxe.cc/) is a very good cross-compiling framework, complete with a suite of libraries
|
||||
that make it extremely easy to port applications to Win32. It runs on pretty much any *nix flavor and generates generic,
|
||||
statically linked Win32 binaries. More information is available in INSTALL-MXE.txt file.
|
||||
statically linked Win32 binaries. More information is available in INSTALL-MXE.md file.
|
||||
|
||||
|
||||
## Compiling on Linux
|
||||
|
@ -65,15 +67,13 @@ be different for different distros:
|
|||
* GLEW >= 1.8.0
|
||||
* libpng >= 1.2
|
||||
* gettext >= 0.18
|
||||
|
||||
For optional sound support (`-DOPENAL_SOUND`):
|
||||
* libsndfile >= 1.0.25
|
||||
* libvorbis >= 1.3.2
|
||||
* libogg >= 1.3.0
|
||||
* OpenAL (OpenAL-Soft) >= 1.13 (optional)
|
||||
* OpenAL (OpenAL-Soft) >= 1.13
|
||||
|
||||
Instructions for compiling are universal:
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Release -DOPENAL_SOUND=1 .
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
$ make
|
||||
|
||||
Everything should compile just fine. If you see any errors, it most likely means missing libraries. Warnings may occur,
|
||||
|
@ -107,8 +107,9 @@ This way, you can keep clean the directory with your source files. Example of us
|
|||
$ make
|
||||
|
||||
|
||||
If you want to submit debug reports, please use Debug builds (`-DCMAKE_BUILD_TYPE=Debug`) and run the game in debug mode and with
|
||||
logging on higher level (commandline arguments: `-debug -loglevel debug`). Also, `-help` will give full list of available arguments.
|
||||
If you want to submit debug reports, please use special Debug and Dev builds (`-DDEV_BUILD=1 -DCMAKE_BUILD_TYPE=Debug`)
|
||||
and run the game in debug mode and with logging on higher level (commandline arguments: `-loglevel debug`).
|
||||
Also, `-help` will give full list of available arguments.
|
||||
|
||||
|
||||
If you encounter any problems, you can get help at our forum or IRC channels.
|
59
README.md
59
README.md
|
@ -4,40 +4,32 @@ Welcome to the Colobot project code repository
|
|||
|
||||
This is official repository for the open-source Colobot project developed by Polish Portal of Colobot (PPC; in Polish: Polski Portal Colobota) with the official site at: http://colobot.info/.
|
||||
|
||||
The source code contained here was released by Epsitec -- the original creator of the game -- on open source (GPLv3) license. The code was given and the rights granted specifically to PPC community in March 2012. Since then, we have been modifying the code and working on our goals, which are briefly summed up below.
|
||||
The source code contained here was released by Epsitec -- the original creator of the game -- on open source (GPLv3) license. The code was given and the rights granted specifically to PPC community in March 2012. Since then, we have been developing the game further.
|
||||
|
||||
More information for developers (in English) can be found on the [developer wiki](https://colobot.info/wiki/Dev:Main_Page). However, the freshest source of information is our IRC channels, see below.
|
||||
More information for developers (in English) can be found on the [developer wiki](https://colobot.info/wiki/Dev:Main_Page) or [our forum](http://colobot.info/forum/). However, the freshest source of information is our IRC channels (see below).
|
||||
|
||||
This repository contains only the source code of the project. The game requires also data files which are now provided as git submodule and are hosted in separate repository (https://github.com/colobot/colobot-data).
|
||||
This repository contains only the source code of the project. The game requires also data files which are now provided as git submodule and are hosted in [separate repository](https://github.com/colobot/colobot-data).
|
||||
|
||||
|
||||
## Status
|
||||
|
||||
Our main goals can be summed up in three milestones:
|
||||
The original version of the game, as released to us by Epsitec, is available as download at [our download site](http://colobot.info/files/) along with original source code and related data files. However, we will not develop this version further, as we focused our efforts on new versions of the game. The original version is also known as Colobot Classic.
|
||||
|
||||
### Milestone 1 - Colobot Classic
|
||||
We are now working on refreshed and updated version of original game, codename Colobot Gold and this is the version currently hosted in this repository. The goal is to rewrite the game engine to be multi-platform, refresh the graphics, include some enhancements and refactor the code to make the game easier to modify.
|
||||
|
||||
This is the original version of the game, as released to us by Epsitec with only minor changes and bugfixes. It is available as a tag named colobot-original in the repository. This version will not be developed further. The compiled version and data packs needed to run the game (split by language version) can also be found at http://colobot.info/files/.
|
||||
The project at this point is in alpha stage - the game is mostly playable, both on Windows and Linux, and most major bugs have been corrected. However, there is still a lot of work to be done. We are now working steadily towards subsequent beta releases, correcting other bugs and introducing enhancements and new features. There is a lot of work ahead and we will gladly accept any and all help.
|
||||
|
||||
### Milestone 2 - Colobot Gold
|
||||
|
||||
This is a version of the game that is currently being developed in this repository. It is based on the original code, but refreshed and rewritten using SDL and OpenGL libraries, thus making it multiplatform.
|
||||
|
||||
Currently (March 2013), we have rewritten all of the original code and we are in the process of testing and fixing issues that are still present in the game. The master branch contains the current snapshot code which should always compile and run with the latest data pack. The dev branch is used for general development.
|
||||
|
||||
### Milestone 3 - Colobot 2
|
||||
|
||||
This will be a new installment in the Colobot series. We have many ideas for the new game and we are still discussing them. Generally, the development of this version will begin only after finishing Colobot Gold (it will be probably hosted in another repository, forked off the Colobot Gold code).
|
||||
In the future, we will begin development on a new installment in the Colobot series, codename Colobot 2. We have many ideas for the new game and we are still discussing them. Generally, the development of this version will begin only after finishing Colobot Gold (it will be probably hosted in another repository, forked off the Colobot Gold code).
|
||||
|
||||
|
||||
## Compiling and running the game
|
||||
|
||||
For these instructions see INSTALL.txt file.
|
||||
For these instructions see INSTALL.md file.
|
||||
|
||||
|
||||
## Contact
|
||||
|
||||
If you want to help in the project, please contact us on our IRC channels or the forum on our website: http://colobot.info/forum (Polish only).
|
||||
If you want to help in the project, please contact us on our IRC channels or [our forum](http://colobot.info/forum/) (Polish, though there is an English board as well).
|
||||
|
||||
### IRC channels
|
||||
|
||||
|
@ -45,43 +37,40 @@ If you want to help in the project, please contact us on our IRC channels or the
|
|||
* [#colobot on Freenode](irc://freenode.net#colobot) in English;
|
||||
|
||||
|
||||
# PL
|
||||
# Polski
|
||||
|
||||
Witamy w repozytorium projektu Colobot
|
||||
|
||||
To jest oficjalne repozytorium z kodem projektu open-source Colobot rozwijanego przez Polski Portal Colobota (PPC; po angielsku: Polish Portal of Colobot) z oficjalną stroną: http://colobot.info/.
|
||||
|
||||
Kod źródłowy zawarty tutaj został wydany przez Epsitec -- oryginalnego twórcę gry -- na otwartej licencji (GPLv3). Kod został wydany i prawa nadane specjalnie dla społeczności PPC w marcu 2012. Od tamtej pory, zajmujemy się modyfikowaniem kodu i pracowaniem nad naszymi celami, które są krótko podsumowane poniżej.
|
||||
Kod źródłowy zawarty tutaj został wydany przez Epsitec -- oryginalnego twórcę gry -- na otwartej licencji (GPLv3). Kod został wydany i prawa nadane specjalnie dla społeczności PPC w marcu 2012. Od tamtej pory, zajmowaliśmy się dalszym rozwojem gry.
|
||||
|
||||
Więcej informacji dla developerów projektu (po angielsku) można znaleźć na [wiki dla developerów](http://colobot.info/wiki/Dev:Main_Page). Jednak źródłem najświeższych informacji jest nasz kanał IRC #colobot na pirc.pl.
|
||||
Więcej informacji dla developerów projektu (po angielsku) można znaleźć na [wiki dla developerów](http://colobot.info/wiki/Dev:Main_Page) lub [naszym forum](http://colobot.info/forum/). Jednak źródłem najświeższych informacji są nasze kanały IRC (patrz niżej).
|
||||
|
||||
To repozytorium zawiera jedynie kod źródłowy projektu. Gra wymaga jeszcze plików danych, które są teraz udostępniane jako submoduł gita i hostowane w osobnym repozytorium ((https://github.com/colobot/colobot-data).
|
||||
To repozytorium zawiera jedynie kod źródłowy projektu. Gra wymaga jeszcze plików danych, które są teraz udostępniane jako submoduł gita i hostowane w [osobnym repozytorium]((https://github.com/colobot/colobot-data).
|
||||
|
||||
|
||||
## Status
|
||||
|
||||
Nasze główne cele można podsumować w trzech cel, które chcemy osiągnąć:
|
||||
Oryginalna wersja gry, jaka została udostępniona nam przez Epsitec, jest dostępna do ściągnięcia na [naszej stronie](http://colobot.info/files/) wraz z oryginalnym kodem źródłowym i związanymi z nią plikami danych. Jednakże nie będziemy zajmować się dalszym rozwojem tej wersji, ponieważ skupiamy nasze wysiłki na tworzenie nowych wersji gry. Oryginalna wersja jest też znana jako Colobot Classic.
|
||||
|
||||
### Cel 1 - Colobot Classic
|
||||
Obecnie pracujemy nad odświeżoną i uaktualnioną wersją oryginalnej gry, którą nazywamy Colobot Gold i jest to wersja obecnie dostępna w tym repozytorium. Celem tego projektu jest przepisanie silnika gry na wersję wieloplatformową, odświeżenie grafiki, dodanie pewnych usprawnień i zrefaktorowanie kodu tak, by dało się łatwiej modyfikować grę.
|
||||
|
||||
To jest oryginalna wersja gry, dokładnie taka, jaką otrzymaliśmy od Epsiteca z jedynie niewielkimi zmianami i poprawkami. Jest dostępna jako tag nazwany colobot-original w repozytorium. Ta wersja nie będzie dalej rozwijana. Skompilowaną wersję wraz z potrzebnymi paczkami danych (podzielone wg wersji językowej) można pobrać z http://colobot.info/files.
|
||||
W tym momencie, gra jest w stadium alpha - gra jest w większości grywalna, pod Windowsem i Linuksem i większość poważnych bugów została poprawiona. Jednakże, jest nadal sporo pracy do zrobienia. Teraz systematycznie pracujemy do kolejnych wydań w fazie beta, poprawiając pozostałe bugi i wprowadzając usprawnienia i nowe funkcje. Jest sporo pracy przed nami i chętnie przyjmiemy pomoc w jakielkolwiek formie.
|
||||
|
||||
### Cel 2 - Colobot Gold
|
||||
|
||||
Jest to wersja gry, którą obecnie rozwijamy w tym repozytorium. Jest oparta na oryginalnym kodzie, ale odświeżonym i przepisanym z wykorzystaniem bibliotek SDL i OpenGL, czyniąc ją wieloplatformową.
|
||||
|
||||
Obecnie (marzec 2013), przepisaliśmy cały oryginalny kod i jesteśmy teraz w trakcie testowania i poprawiania błędów nadal obecnych w grze. Gałąź master zawiera obecny snapshot kodu, który powinien zawsze dać się skompilować i uruchomić z aktualną paczką danych. Gałąź dev jest wykorzystywana do ogólnego rozwoju.
|
||||
|
||||
### Krok 3 - Colobot 2
|
||||
|
||||
To będzie nowa część z cyklu gier Colobot. Mamy wiele pomysłów na nową grę i nadal dyskutujemy nad nimi. Ogólnie, rozwój tej wersji zacznie się po skończeniu wersji Colobot Gold (prawdopodobnie będzie hostowane w osobnym repozytorium, sforkowanym z kodu Colobot Gold).
|
||||
W przyszłości, planujemy rozpocząć prace nad nową częścią z serii Colobot, pod nazwą Colobot 2.Mamy wiele pomysłów na nową grę i nadal dyskutujemy nad nimi. Ogólnie, rozwój tej wersji zacznie się po skończeniu wersji Colobot Gold (prawdopodobnie będzie hostowane w osobnym repozytorium, sforkowanym z kodu Colobot Gold).
|
||||
|
||||
|
||||
## Kompilacja i uruchomienie gry
|
||||
|
||||
Instrukcje te znajdują się w pliku INSTALL.txt (po angielsku).
|
||||
Instrukcje te znajdują się w pliku INSTALL.md (po angielsku).
|
||||
|
||||
|
||||
## Kontakt
|
||||
|
||||
Jeżeli chcesz pomóc w projekcie, prosimy o kontakt na naszym kanale IRC: #colobot na pirc.pl (po polsku i angielsku) albo na forum na naszej stronie: http://colobot.info/forum (jedynie polski).
|
||||
Jeżeli chcesz pomóc w projekcie, prosimy o kontakt na naszych kanałach IRC lub [naszym forum](http://colobot.info/forum/).
|
||||
|
||||
### Kanały IRC
|
||||
|
||||
* [#colobot on pirc.pl](irc://pirc.pl#colobot) polski;
|
||||
* [#colobot on Freenode](irc://freenode.net#colobot) angielski;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# Ignore everything
|
||||
*
|
||||
|
||||
# But not these files...
|
||||
!.gitignore
|
||||
!README.txt
|
|
@ -1 +0,0 @@
|
|||
Target directory for binary objects: colobot.exe and CBot/libCBot.dll
|
|
@ -0,0 +1,218 @@
|
|||
##
|
||||
# Patched version of original CMake module
|
||||
# Added variable GETTEXT_INSTALL_PREFIX to optionally override installation path of resulting translations
|
||||
##
|
||||
|
||||
# - Find GNU gettext tools
|
||||
# This module looks for the GNU gettext tools. This module defines the
|
||||
# following values:
|
||||
# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
|
||||
# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
|
||||
# GETTEXT_FOUND: True if gettext has been found.
|
||||
# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
|
||||
#
|
||||
# Additionally it provides the following macros:
|
||||
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
|
||||
# This will create a target "translations" which will convert the
|
||||
# given input po files into the binary output mo file. If the
|
||||
# ALL option is used, the translations will also be created when
|
||||
# building the default target.
|
||||
# GETTEXT_PROCESS_POT( <potfile> [ALL] [INSTALL_DESTINATION <destdir>] LANGUAGES <lang1> <lang2> ... )
|
||||
# Process the given pot file to mo files.
|
||||
# If INSTALL_DESTINATION is given then automatically install rules will be created,
|
||||
# the language subdirectory will be taken into account (by default use share/locale/).
|
||||
# If ALL is specified, the pot file is processed when building the all traget.
|
||||
# It creates a custom target "potfile".
|
||||
# GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>] PO_FILES <po1> <po2> ... )
|
||||
# Process the given po files to mo files for the given language.
|
||||
# If INSTALL_DESTINATION is given then automatically install rules will be created,
|
||||
# the language subdirectory will be taken into account (by default use share/locale/).
|
||||
# If ALL is specified, the po files are processed when building the all traget.
|
||||
# It creates a custom target "pofiles".
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
# Copyright 2007 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# 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.)
|
||||
|
||||
find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
|
||||
|
||||
find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
|
||||
|
||||
if(GETTEXT_MSGMERGE_EXECUTABLE)
|
||||
execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE gettext_version
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]")
|
||||
string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}")
|
||||
endif()
|
||||
unset(gettext_version)
|
||||
endif()
|
||||
|
||||
set(GETTEXT_INSTALL_PREFIX share/locale)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext
|
||||
REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE
|
||||
VERSION_VAR GETTEXT_VERSION_STRING)
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name)
|
||||
set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
|
||||
get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
|
||||
if(NOT currentCounter)
|
||||
set(currentCounter 1)
|
||||
endif()
|
||||
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
|
||||
math(EXPR currentCounter "${currentCounter} + 1")
|
||||
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
|
||||
endfunction()
|
||||
|
||||
macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
|
||||
# make it a real variable, so we can modify it here
|
||||
set(_firstPoFile "${_firstPoFileArg}")
|
||||
|
||||
set(_gmoFiles)
|
||||
get_filename_component(_potName ${_potFile} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
|
||||
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
|
||||
|
||||
set(_addToAll)
|
||||
if(${_firstPoFile} STREQUAL "ALL")
|
||||
set(_addToAll "ALL")
|
||||
set(_firstPoFile)
|
||||
endif()
|
||||
|
||||
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
|
||||
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
|
||||
get_filename_component(_abs_PATH ${_absFile} PATH)
|
||||
get_filename_component(_lang ${_absFile} NAME_WE)
|
||||
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${_gmoFile}
|
||||
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
|
||||
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
|
||||
DEPENDS ${_absPotFile} ${_absFile}
|
||||
)
|
||||
|
||||
install(FILES ${_gmoFile} DESTINATION ${GETTEXT_INSTALL_PREFIX}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
|
||||
set(_gmoFiles ${_gmoFiles} ${_gmoFile})
|
||||
|
||||
endforeach ()
|
||||
|
||||
if(NOT TARGET translations)
|
||||
add_custom_target(translations)
|
||||
endif()
|
||||
|
||||
_GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName)
|
||||
|
||||
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
|
||||
|
||||
add_dependencies(translations ${uniqueTargetName})
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
function(GETTEXT_PROCESS_POT_FILE _potFile)
|
||||
set(_gmoFiles)
|
||||
set(_options ALL)
|
||||
set(_oneValueArgs INSTALL_DESTINATION)
|
||||
set(_multiValueArgs LANGUAGES)
|
||||
|
||||
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
|
||||
|
||||
get_filename_component(_potName ${_potFile} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
|
||||
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
|
||||
|
||||
foreach (_lang ${_parsedArguments_LANGUAGES})
|
||||
set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
|
||||
set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${_poFile}"
|
||||
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
|
||||
DEPENDS ${_absPotFile}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${_gmoFile}"
|
||||
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
|
||||
DEPENDS ${_absPotFile} ${_poFile}
|
||||
)
|
||||
|
||||
if(_parsedArguments_INSTALL_DESTINATION)
|
||||
install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
|
||||
endif()
|
||||
list(APPEND _gmoFiles ${_gmoFile})
|
||||
endforeach ()
|
||||
|
||||
if(NOT TARGET potfiles)
|
||||
add_custom_target(potfiles)
|
||||
endif()
|
||||
|
||||
_GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName)
|
||||
|
||||
if(_parsedArguments_ALL)
|
||||
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
|
||||
else()
|
||||
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
|
||||
endif()
|
||||
|
||||
add_dependencies(potfiles ${uniqueTargetName})
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
function(GETTEXT_PROCESS_PO_FILES _lang)
|
||||
set(_options ALL)
|
||||
set(_oneValueArgs INSTALL_DESTINATION)
|
||||
set(_multiValueArgs PO_FILES)
|
||||
set(_gmoFiles)
|
||||
|
||||
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
|
||||
|
||||
foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
|
||||
get_filename_component(_name ${_current_PO_FILE} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
|
||||
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
|
||||
add_custom_command(OUTPUT ${_gmoFile}
|
||||
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
DEPENDS ${_current_PO_FILE}
|
||||
)
|
||||
|
||||
if(_parsedArguments_INSTALL_DESTINATION)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
|
||||
endif()
|
||||
list(APPEND _gmoFiles ${_gmoFile})
|
||||
endforeach()
|
||||
|
||||
|
||||
if(NOT TARGET pofiles)
|
||||
add_custom_target(pofiles)
|
||||
endif()
|
||||
|
||||
_GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
|
||||
|
||||
if(_parsedArguments_ALL)
|
||||
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
|
||||
else()
|
||||
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
|
||||
endif()
|
||||
|
||||
add_dependencies(pofiles ${uniqueTargetName})
|
||||
|
||||
endfunction()
|
2
data
2
data
|
@ -1 +1 @@
|
|||
Subproject commit 827236ef15f105613f083bf3aeb1629b13ba2f50
|
||||
Subproject commit 2d7172438e8db1fa6d73d1c5f314489f8c936c1b
|
|
@ -0,0 +1,7 @@
|
|||
lang/
|
||||
fr/
|
||||
16/
|
||||
32/
|
||||
48/
|
||||
colobot.6
|
||||
colobot.desktop
|
|
@ -0,0 +1,99 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Install Desktop Entry file
|
||||
set(COLOBOT_DESKTOP_FILE colobot.desktop)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
|
||||
)
|
||||
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
|
||||
)
|
||||
|
||||
# Install Icon
|
||||
set(COLOBOT_ICON_FILE colobot.svg)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
|
||||
)
|
||||
|
||||
# Render SVG icon in various sizes
|
||||
find_program(RSVG_CONVERT rsvg-convert)
|
||||
if(RSVG_CONVERT)
|
||||
foreach(PNGSIZE "48" "32" "16")
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE})
|
||||
add_custom_target(resize_icon_${PNGSIZE} ALL
|
||||
COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
> ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Create manpage from pod-formatted file
|
||||
find_program(POD2MAN pod2man)
|
||||
if(POD2MAN)
|
||||
set(COLOBOT_MANPAGE_SECTION 6)
|
||||
|
||||
macro(podman)
|
||||
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
|
||||
if(PM_LOCALE)
|
||||
# This copes with the fact that english has no "/LANG" in the paths and filenames.
|
||||
set(SLASHLOCALE /${PM_LOCALE})
|
||||
endif()
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
||||
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
|
||||
--center="Colobot" --stderr --utf8
|
||||
--release="${COLOBOT_VERSION_FULL}"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
|
||||
)
|
||||
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
|
||||
|
||||
add_dependencies(man man${PM_LOCALE})
|
||||
endmacro()
|
||||
|
||||
# Create the english manpage
|
||||
podman(PODFILE colobot.pod)
|
||||
|
||||
endif()
|
||||
|
||||
# Translate translatable material
|
||||
find_program(PO4A po4a)
|
||||
|
||||
if(PO4A)
|
||||
add_custom_target(desktop_po4a
|
||||
COMMAND ${PO4A} po4a.cfg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(desktopfile desktop_po4a)
|
||||
|
||||
if(POD2MAN)
|
||||
add_custom_target(man_po4a
|
||||
COMMAND ${PO4A} po4a.cfg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(man man_po4a)
|
||||
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
|
||||
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
|
||||
foreach(LOCALE ${LINGUAS})
|
||||
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
|
||||
add_dependencies(man${PM_LOCALE} man_po4a)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
|
@ -4,3 +4,4 @@ Type=Application
|
|||
Exec=colobot
|
||||
Icon=colobot
|
||||
Categories=Education;Robotics;Game;AdventureGame;StrategyGame;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
Name="Colobot"
|
||||
GenericName="Game to learn programming"
|
||||
Comment="Colonize with bots"
|
||||
|
|
@ -45,3 +45,4 @@ Set language. Note that you can also fill the B<LANG> environment variable.
|
|||
=head1 AUTHOR
|
||||
|
||||
This manpage was written by Didier Raboud <S<odyx@debian.org>>.
|
||||
|
|
@ -236,3 +236,4 @@
|
|||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
|
@ -11,8 +11,8 @@ cat colobot.desktop.in
|
|||
linguas=$([ ! -d lang ] || ( cd lang ; ls));
|
||||
|
||||
for type in Name GenericName Comment; do
|
||||
egrep "^$type=" $fname | sed -e "s/^$type=\"\(.*\)\"$/$type=\1/g"
|
||||
for l in $linguas; do
|
||||
egrep "^$type=" lang/$l/$fname | sed -e "s/^$type=\"\(.*\)\"$/$type[$l]=\1/g"
|
||||
done
|
||||
egrep "^$type=" $fname | sed -e "s/^$type=\"\(.*\)\"$/$type=\1/g"
|
||||
for l in $linguas; do
|
||||
egrep "^$type=" lang/$l/$fname | sed -e "s/^$type=\"\(.*\)\"$/$type[$l]=\1/g"
|
||||
done
|
||||
done
|
|
@ -132,3 +132,4 @@ msgstr ""
|
|||
#: colobot.pod:47
|
||||
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
|
||||
msgstr ""
|
||||
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
[type:ini] colobot.ini $lang:lang/$lang/colobot.ini
|
||||
[type:pod] colobot.pod $lang:lang/$lang/colobot.pod
|
||||
|
|
@ -0,0 +1 @@
|
|||
libclipboard.a
|
|
@ -0,0 +1,17 @@
|
|||
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_LINUX)
|
||||
set(CLIPBOARD_SRC src/clipboardX11.c)
|
||||
else()
|
||||
set(CLIPBOARD_SRC src/clipboardX11.c)
|
||||
endif()
|
||||
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
add_library(clipboard STATIC src/utf.c ${CLIPBOARD_SRC})
|
|
@ -0,0 +1,72 @@
|
|||
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
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
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_*/
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
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__
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
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__
|
|
@ -0,0 +1,614 @@
|
|||
/*
|
||||
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 */
|
|
@ -0,0 +1 @@
|
|||
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.
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,530 @@
|
|||
/*
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
add_library(localename STATIC localename.c)
|
|
@ -0,0 +1,41 @@
|
|||
Part of gnulib library (http://www.gnu.org/software/gnulib/)
|
||||
|
||||
Original source with added patch to also include LANGUAGE environment variable.
|
||||
|
||||
Orignal module description below
|
||||
|
||||
================================
|
||||
|
||||
Description:
|
||||
Return current locale's name, according to glibc naming conventions.
|
||||
|
||||
Files:
|
||||
lib/localename.h
|
||||
lib/localename.c
|
||||
m4/localename.m4
|
||||
m4/intlmacosx.m4
|
||||
m4/lcmessage.m4
|
||||
|
||||
Depends-on:
|
||||
strdup
|
||||
lock
|
||||
|
||||
configure.ac:
|
||||
gl_LOCALENAME
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += localename.c
|
||||
|
||||
Include:
|
||||
"localename.h"
|
||||
|
||||
Link:
|
||||
@INTL_MACOSX_LIBS@
|
||||
$(LTLIBTHREAD) when linking with libtool, $(LIBTHREAD) otherwise
|
||||
|
||||
License:
|
||||
LGPLv2+
|
||||
|
||||
Maintainer:
|
||||
Bruno Haible
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,95 @@
|
|||
/* Determine name of the currently selected locale.
|
||||
Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GL_LOCALENAME_H
|
||||
#define _GL_LOCALENAME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine the current locale's name.
|
||||
It considers both the POSIX notion of locale name (see functions
|
||||
gl_locale_name_thread and gl_locale_name_posix) and the system notion
|
||||
of locale name (see function gl_locale_name_default).
|
||||
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
|
||||
but not LC_ALL. E.g. LC_MESSAGES.
|
||||
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
|
||||
Return the locale category's name, canonicalized into XPG syntax
|
||||
language[_territory][.codeset][@modifier]
|
||||
The codeset part in the result is not reliable; the locale_charset()
|
||||
should be used for codeset information instead.
|
||||
The result must not be freed; it is statically allocated. */
|
||||
extern const char * gl_locale_name (int category, const char *categoryname);
|
||||
|
||||
/* Determine the current per-thread locale's name, as specified by uselocale()
|
||||
calls.
|
||||
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
|
||||
but not LC_ALL. E.g. LC_MESSAGES.
|
||||
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
|
||||
Return the locale category's name, canonicalized into XPG syntax
|
||||
language[_territory][.codeset][@modifier]
|
||||
or NULL if no locale has been specified for the current thread.
|
||||
The codeset part in the result is not reliable; the locale_charset()
|
||||
should be used for codeset information instead.
|
||||
The result must not be freed; it is statically allocated. */
|
||||
extern const char * gl_locale_name_thread (int category, const char *categoryname);
|
||||
|
||||
/* Determine the thread-independent current locale's name, as specified by
|
||||
setlocale() calls or by environment variables.
|
||||
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
|
||||
but not LC_ALL. E.g. LC_MESSAGES.
|
||||
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
|
||||
Return the locale category's name, canonicalized into XPG syntax
|
||||
language[_territory][.codeset][@modifier]
|
||||
or NULL if no locale has been specified to setlocale() or by environment
|
||||
variables.
|
||||
The codeset part in the result is not reliable; the locale_charset()
|
||||
should be used for codeset information instead.
|
||||
The result must not be freed; it is statically allocated. */
|
||||
extern const char * gl_locale_name_posix (int category, const char *categoryname);
|
||||
|
||||
/* Determine the default locale's name, as specified by environment
|
||||
variables.
|
||||
Return the locale category's name, or NULL if no locale has been specified
|
||||
by environment variables.
|
||||
The result must not be freed; it is statically allocated. */
|
||||
extern const char * gl_locale_name_environ (int category, const char *categoryname);
|
||||
|
||||
/* Determine the default locale's name. This is the current locale's name,
|
||||
if not specified by uselocale() calls, by setlocale() calls, or by
|
||||
environment variables. This locale name is usually determined by systems
|
||||
settings that the user can manipulate through a GUI.
|
||||
|
||||
Quoting POSIX:2001:
|
||||
"All implementations shall define a locale as the default locale,
|
||||
to be invoked when no environment variables are set, or set to the
|
||||
empty string. This default locale can be the C locale or any other
|
||||
implementation-defined locale. Some implementations may provide
|
||||
facilities for local installation administrators to set the default
|
||||
locale, customizing it for each location. IEEE Std 1003.1-2001 does
|
||||
not require such a facility."
|
||||
|
||||
The result must not be freed; it is statically allocated. */
|
||||
extern const char * gl_locale_name_default (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_LOCALENAME_H */
|
|
@ -0,0 +1 @@
|
|||
*.gmo
|
|
@ -5,8 +5,8 @@ set(_potFile colobot.pot)
|
|||
find_program(XGETTEXT_CMD xgettext)
|
||||
|
||||
add_custom_command(OUTPUT ${_potFile}
|
||||
COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile}
|
||||
COMMAND ${XGETTEXT_CMD} ../common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location
|
||||
COMMAND ${XGETTEXT_CMD} ${colobot_SOURCE_DIR}/src/app/app.cpp --output=${_potFile}
|
||||
COMMAND ${XGETTEXT_CMD} ${colobot_SOURCE_DIR}/src/common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location
|
||||
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Extract translatable messages to ${_potFile}"
|
||||
|
@ -15,4 +15,6 @@ add_custom_command(OUTPUT ${_potFile}
|
|||
add_custom_target(update-pot DEPENDS ${_potFile})
|
||||
|
||||
file(GLOB _poFiles *.po)
|
||||
set(GETTEXT_INSTALL_PREFIX ${COLOBOT_INSTALL_I18N_DIR})
|
||||
gettext_create_translations(${_potFile} ALL ${_poFiles})
|
||||
|
|
@ -1816,3 +1816,4 @@ msgstr ""
|
|||
|
||||
msgid "%1"
|
||||
msgstr ""
|
||||
|
|
@ -2053,3 +2053,4 @@ msgstr "www.epsitec.com"
|
|||
|
||||
#~ msgid "Zoom"
|
||||
#~ msgstr "Zoom"
|
||||
|
|
@ -2055,3 +2055,4 @@ msgstr "www.epsitec.com"
|
|||
|
||||
#~ msgid "Zoom"
|
||||
#~ msgstr "Zoom"
|
||||
|
|
@ -2063,3 +2063,4 @@ msgstr "www.epsitec.com"
|
|||
|
||||
#~ msgid "Zoom"
|
||||
#~ msgstr "Powiększenie"
|
||||
|
|
@ -0,0 +1 @@
|
|||
libCBot.so
|
|
@ -186,7 +186,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
{
|
||||
type = pp->GetType();
|
||||
// these instructions accept only lable
|
||||
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0))
|
||||
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, 0))
|
||||
{
|
||||
pStack->SetError(TX_LABEL, pp->GetStart());
|
||||
return NULL;
|
||||
|
@ -205,9 +205,6 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
case ID_DO:
|
||||
return CBotDo::Compile(p, pStack);
|
||||
|
||||
case ID_REPEAT:
|
||||
return CBotRepeat::Compile(p, pStack);
|
||||
|
||||
case ID_BREAK:
|
||||
case ID_CONTINUE:
|
||||
return CBotBreak::Compile(p, pStack);
|
||||
|
@ -513,7 +510,7 @@ CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return inst;
|
||||
}
|
||||
|
||||
// creates a variable and assigns the result to the stack
|
||||
// creates a variable and assigns the result to the stack
|
||||
bool CBotLeftExprVar::Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotVar* var1;
|
||||
|
@ -1076,7 +1073,7 @@ bool CBotInt::Execute(CBotStack* &pj)
|
|||
|
||||
if (pile->IfStep()) return false;
|
||||
|
||||
if ( m_next2b &&
|
||||
if ( m_next2b &&
|
||||
!m_next2b->Execute(pile)) return false; // other(s) definition(s)
|
||||
|
||||
return pj->Return(pile); // forward below
|
||||
|
@ -1561,8 +1558,8 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
int OpType = p->GetType();
|
||||
|
||||
if ( pStack->IsOk() &&
|
||||
IsOfTypeList(p, ID_ASS, ID_ASSADD, ID_ASSSUB, ID_ASSMUL, ID_ASSDIV, ID_ASSMODULO,
|
||||
ID_ASSAND, ID_ASSXOR, ID_ASSOR,
|
||||
IsOfTypeList(p, ID_ASS, ID_ASSADD, ID_ASSSUB, ID_ASSMUL, ID_ASSDIV, ID_ASSMODULO,
|
||||
ID_ASSAND, ID_ASSXOR, ID_ASSOR,
|
||||
ID_ASSSL , ID_ASSSR, ID_ASSASR, 0 ))
|
||||
{
|
||||
if (inst->m_leftop == NULL)
|
||||
|
@ -1658,7 +1655,7 @@ bool CBotExpression::Execute(CBotStack* &pj)
|
|||
CBotStack* pile = pj->AddStack(this);
|
||||
|
||||
// CBotToken* pToken = m_leftop->GetToken();
|
||||
|
||||
|
||||
CBotVar* pVar = NULL;
|
||||
|
||||
CBotStack* pile1 = pile;
|
||||
|
@ -1714,13 +1711,13 @@ bool CBotExpression::Execute(CBotStack* &pj)
|
|||
pile2->SetVar(result);
|
||||
break;
|
||||
case ID_ASSDIV:
|
||||
if (IsInit &&
|
||||
if (IsInit &&
|
||||
result->Div(pile1->GetVar(), pile2->GetVar()))
|
||||
pile2->SetError(TX_DIVZERO, &m_token);
|
||||
pile2->SetVar(result);
|
||||
break;
|
||||
case ID_ASSMODULO:
|
||||
if (IsInit &&
|
||||
if (IsInit &&
|
||||
result->Modulo(pile1->GetVar(), pile2->GetVar()))
|
||||
pile2->SetError(TX_DIVZERO, &m_token);
|
||||
pile2->SetVar(result);
|
||||
|
@ -1779,7 +1776,7 @@ void CBotExpression::RestoreState(CBotStack* &pj, bool bMain)
|
|||
|
||||
if ( pile1->GetState()==0)
|
||||
{
|
||||
m_leftop->RestoreStateVar(pile, true);
|
||||
m_leftop->RestoreStateVar(pile, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1972,7 +1969,7 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
}
|
||||
|
||||
// is it a number or DefineNum?
|
||||
if (p->GetType() == TokenTypNum ||
|
||||
if (p->GetType() == TokenTypNum ||
|
||||
p->GetType() == TokenTypDef )
|
||||
{
|
||||
CBotInstr* inst = CBotExprNum::Compile(p, pStk);
|
||||
|
@ -2069,7 +2066,7 @@ bool CBotPostIncExpr::Execute(CBotStack* &pj)
|
|||
pile1->SetState(1);
|
||||
pile1->SetCopyVar(var1); // places the result (before incrementation);
|
||||
|
||||
CBotStack* pile3 = pile2->AddStack(this);
|
||||
CBotStack* pile3 = pile2->AddStack(this);
|
||||
if (pile3->IfStep()) return false;
|
||||
|
||||
if (var1->GetInit() == IS_NAN)
|
||||
|
@ -2324,7 +2321,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
|
|||
|
||||
pVar->Maj(pile->GetPUser(), true);
|
||||
|
||||
if ( m_next3 != NULL &&
|
||||
if ( m_next3 != NULL &&
|
||||
!m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return false;
|
||||
|
||||
// does not release the stack
|
||||
|
@ -2343,7 +2340,7 @@ void CBotIndexExpr::RestoreStateVar(CBotStack* &pile, bool bMain)
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_next3)
|
||||
if (m_next3)
|
||||
m_next3->RestoreStateVar(pile, bMain);
|
||||
}
|
||||
|
||||
|
@ -2431,7 +2428,7 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
|
|||
// request the update of the element, if applicable
|
||||
pVar->Maj(pile->GetPUser(), true);
|
||||
|
||||
if ( m_next3 != NULL &&
|
||||
if ( m_next3 != NULL &&
|
||||
!m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return false;
|
||||
|
||||
// does not release the stack
|
||||
|
@ -2445,7 +2442,7 @@ void CBotFieldExpr::RestoreStateVar(CBotStack* &pj, bool bMain)
|
|||
pj = pj->RestoreStack(this);
|
||||
if (pj == NULL) return;
|
||||
|
||||
if (m_next3 != NULL)
|
||||
if (m_next3 != NULL)
|
||||
m_next3->RestoreStateVar(pj, bMain);
|
||||
}
|
||||
|
||||
|
@ -2659,7 +2656,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT
|
|||
|
||||
if (bStep && m_next3 == NULL && pile->IfStep()) return false;
|
||||
|
||||
if ( m_next3 != NULL &&
|
||||
if ( m_next3 != NULL &&
|
||||
!m_next3->ExecuteVar(pVar, pile, &m_token, bStep, true) ) return false;
|
||||
|
||||
return true;
|
||||
|
@ -2670,7 +2667,7 @@ void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, bool bMain)
|
|||
pile = pile->RestoreStack(this);
|
||||
if (pile == NULL) return;
|
||||
|
||||
if (m_next3 != NULL)
|
||||
if (m_next3 != NULL)
|
||||
m_next3->RestoreStateVar(pile, bMain);
|
||||
}
|
||||
|
||||
|
@ -3098,7 +3095,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat)
|
|||
{
|
||||
if (var->GetType() == CBotTypArrayPointer)
|
||||
{
|
||||
if (IsOfType( p, ID_OPBRK )) // check if there is an aindex
|
||||
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
|
||||
|
@ -3415,7 +3412,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
|
|||
{
|
||||
CBotClass* pClass = var->GetClass(); // pointer to the class
|
||||
inst->m_ClassName = pClass->GetName(); // name of the class
|
||||
CBotTypResult r = pClass->CompileMethode(inst->m_NomMethod, var, ppVars,
|
||||
CBotTypResult r = pClass->CompileMethode(inst->m_NomMethod, var, ppVars,
|
||||
pStack, inst->m_MethodeIdent);
|
||||
delete pStack->TokenStack(); // release parameters on the stack
|
||||
inst->m_typRes = r;
|
||||
|
@ -3507,8 +3504,8 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
|
|||
}
|
||||
CBotVar* pRes = pResult;
|
||||
|
||||
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars,
|
||||
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars,
|
||||
pResult, pile2, GetToken())) return false;
|
||||
if (pRes != pResult) delete pRes;
|
||||
|
||||
|
@ -3558,7 +3555,7 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain)
|
|||
|
||||
// CBotVar* pRes = pResult;
|
||||
|
||||
pClass->RestoreMethode(m_MethodeIdent, m_NomMethod,
|
||||
pClass->RestoreMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars, pile2);
|
||||
}
|
||||
|
||||
|
@ -3612,8 +3609,8 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
|
|||
}
|
||||
CBotVar* pRes = pResult;
|
||||
|
||||
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars,
|
||||
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars,
|
||||
pResult, pile2, GetToken())) return false; // interupted
|
||||
|
||||
// set the new value of this in place of the old variable
|
||||
|
@ -3628,7 +3625,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// compile an instruction "new"
|
||||
// compile an instruction "new"
|
||||
|
||||
CBotNew::CBotNew()
|
||||
{
|
||||
|
@ -3773,8 +3770,8 @@ bool CBotNew::Execute(CBotStack* &pj)
|
|||
// create a variable for the result
|
||||
CBotVar* pResult = NULL; // constructos still void
|
||||
|
||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||
pThis, ppVars,
|
||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||
pThis, ppVars,
|
||||
pResult, pile2, GetToken())) return false; // interrupt
|
||||
|
||||
pThis->ConstructorSet(); // indicates that the constructor has been called
|
||||
|
@ -3860,13 +3857,13 @@ bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op)
|
|||
|
||||
if (max >= CBotTypBoolean)
|
||||
{
|
||||
if ( (op == ID_EQ || op == ID_NE) &&
|
||||
if ( (op == ID_EQ || op == ID_NE) &&
|
||||
(t1 == CBotTypPointer && t2 == CBotTypNullPointer)) return true;
|
||||
if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) &&
|
||||
if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) &&
|
||||
(t2 == CBotTypPointer && t1 == CBotTypNullPointer)) return true;
|
||||
if ( (op == ID_EQ || op == ID_NE) &&
|
||||
if ( (op == ID_EQ || op == ID_NE) &&
|
||||
(t1 == CBotTypArrayPointer && t2 == CBotTypNullPointer)) return true;
|
||||
if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) &&
|
||||
if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) &&
|
||||
(t2 == CBotTypArrayPointer && t1 == CBotTypNullPointer)) return true;
|
||||
if (t2 != t1) return false;
|
||||
if (t1 == CBotTypArrayPointer) return type1.Compare(type2);
|
||||
|
|
|
@ -57,7 +57,6 @@ class CBotExprVar; // a variable name as
|
|||
class CBotWhile; // while (...) {...};
|
||||
class CBotIf; // if (...) {...} else {...}
|
||||
class CBotDefParam; // paramerer list of a function
|
||||
class CBotRepeat; // repeat (nb) {...}
|
||||
|
||||
|
||||
|
||||
|
@ -70,7 +69,7 @@ class CBotRepeat; // repeat (nb) {...}
|
|||
// to use for routine CBotProgram :: Execute (CBotStack)
|
||||
|
||||
|
||||
/**\class CBotStack
|
||||
/**\class CBotStack
|
||||
* \brief Management of the execution stack.
|
||||
* \brief Actually the only thing it can do is to create an instance of a stack
|
||||
* \brief to use for routine CBotProgram :: Execute(CBotStack)*/
|
||||
|
@ -211,14 +210,14 @@ public:
|
|||
// in case of eventual break
|
||||
bool IfContinue(int state, const char* name);
|
||||
// or "continue"
|
||||
|
||||
|
||||
bool IsOk();
|
||||
|
||||
bool SetState(int n, int lim = -10); // select a state
|
||||
int GetState(); // in what state am I?
|
||||
bool IncState(int lim = -10); // passes to the next state
|
||||
bool IfStep(); // do step by step
|
||||
bool Execute();
|
||||
bool Execute();
|
||||
|
||||
void SetVar( CBotVar* var );
|
||||
void SetCopyVar( CBotVar* var );
|
||||
|
@ -260,7 +259,7 @@ private:
|
|||
CBotStack* m_prev;
|
||||
friend class CBotInstArray;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
int m_index;
|
||||
#endif
|
||||
int m_state;
|
||||
|
@ -361,7 +360,7 @@ public:
|
|||
CBotCStack* TokenStack(CBotToken* pToken = NULL, bool bBlock = false);
|
||||
CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmits the result upper
|
||||
CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmits the result upper
|
||||
|
||||
|
||||
void SetVar( CBotVar* var );
|
||||
void SetCopyVar( CBotVar* var );
|
||||
CBotVar* GetVar();
|
||||
|
@ -481,7 +480,7 @@ class CBotWhile : public CBotInstr
|
|||
private:
|
||||
CBotInstr* m_Condition; // condition
|
||||
CBotInstr* m_Block; // instructions
|
||||
CBotString m_label; // a label if there is
|
||||
CBotString m_label; // a label if there is
|
||||
|
||||
public:
|
||||
CBotWhile();
|
||||
|
@ -492,38 +491,12 @@ public:
|
|||
void RestoreState(CBotStack* &pj, bool bMain);
|
||||
};
|
||||
|
||||
class CBotRepeat : public CBotInstr
|
||||
{
|
||||
private:
|
||||
/// Number of iterations
|
||||
CBotInstr* m_NbIter;
|
||||
|
||||
/// Instructions
|
||||
CBotInstr* m_Block;
|
||||
|
||||
/// Label
|
||||
CBotString m_label; // a label if there is
|
||||
|
||||
public:
|
||||
CBotRepeat();
|
||||
~CBotRepeat();
|
||||
|
||||
/// Static method used for compilation
|
||||
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
||||
|
||||
/// Execute
|
||||
bool Execute(CBotStack* &pj);
|
||||
|
||||
/// Restore state
|
||||
void RestoreState(CBotStack* &pj, bool bMain);
|
||||
};
|
||||
|
||||
class CBotDo : public CBotInstr
|
||||
{
|
||||
private:
|
||||
CBotInstr* m_Block; // instruction
|
||||
CBotInstr* m_Condition; // conditions
|
||||
CBotString m_label; // a label if there is
|
||||
CBotString m_label; // a label if there is
|
||||
|
||||
public:
|
||||
CBotDo();
|
||||
|
@ -541,7 +514,7 @@ private:
|
|||
CBotInstr* m_Test; // test condition
|
||||
CBotInstr* m_Incr; // instruction for increment
|
||||
CBotInstr* m_Block; // instructions
|
||||
CBotString m_label; // a label if there is
|
||||
CBotString m_label; // a label if there is
|
||||
|
||||
public:
|
||||
CBotFor();
|
||||
|
@ -555,7 +528,7 @@ public:
|
|||
class CBotBreak : public CBotInstr
|
||||
{
|
||||
private:
|
||||
CBotString m_label; // a label if there is
|
||||
CBotString m_label; // a label if there is
|
||||
|
||||
public:
|
||||
CBotBreak();
|
||||
|
@ -569,7 +542,7 @@ public:
|
|||
class CBotReturn : public CBotInstr
|
||||
{
|
||||
private:
|
||||
CBotInstr* m_Instr; // paramter of return
|
||||
CBotInstr* m_Instr; // paramter of return
|
||||
|
||||
public:
|
||||
CBotReturn();
|
||||
|
@ -584,7 +557,7 @@ public:
|
|||
class CBotSwitch : public CBotInstr
|
||||
{
|
||||
private:
|
||||
CBotInstr* m_Value; // value to seek
|
||||
CBotInstr* m_Value; // value to seek
|
||||
CBotInstr* m_Block; // instructions
|
||||
|
||||
public:
|
||||
|
@ -731,7 +704,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// definition of a assignment list for a table
|
||||
// definition of a assignment list for a table
|
||||
// int [ ] a [ ] = ( ( 1, 2, 3 ) , ( 3, 2, 1 ) ) ;
|
||||
|
||||
class CBotListArray : public CBotInstr
|
||||
|
@ -1442,12 +1415,12 @@ public:
|
|||
void IncrementUse(); // a reference to incrementation
|
||||
void DecrementUse(); // a reference to decrementation
|
||||
|
||||
CBotVarClass*
|
||||
CBotVarClass*
|
||||
GetPointer();
|
||||
void SetItemList(CBotVar* pVar);
|
||||
|
||||
void SetIdent(long n);
|
||||
|
||||
|
||||
static CBotVarClass* Find(long id);
|
||||
|
||||
|
||||
|
@ -1516,7 +1489,7 @@ public:
|
|||
void SetPointer(CBotVar* p);
|
||||
CBotVarClass*
|
||||
GetPointer();
|
||||
|
||||
|
||||
void Copy(CBotVar* pSrc, bool bName=true);
|
||||
CBotVar* GetItem(int n, bool bGrow=false); // makes an element according to its numeric index
|
||||
// enlarged the table if necessary if bExtend
|
||||
|
@ -1571,14 +1544,14 @@ private:
|
|||
CBotCall* m_next;
|
||||
|
||||
public:
|
||||
CBotCall(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotCall(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
|
||||
~CBotCall();
|
||||
|
||||
static
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
|
||||
|
||||
static
|
||||
|
@ -1599,7 +1572,7 @@ public:
|
|||
|
||||
CBotString GetName();
|
||||
CBotCall* Next();
|
||||
|
||||
|
||||
static void SetPUser(void* pUser);
|
||||
static void Free();
|
||||
};
|
||||
|
@ -1618,13 +1591,13 @@ private:
|
|||
long m_nFuncIdent;
|
||||
|
||||
public:
|
||||
CBotCallMethode(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotCallMethode(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
|
||||
~CBotCallMethode();
|
||||
|
||||
CBotTypResult
|
||||
CompileCall(const char* name, CBotVar* pThis,
|
||||
CompileCall(const char* name, CBotVar* pThis,
|
||||
CBotVar** ppVars, CBotCStack* pStack,
|
||||
long& nIdent);
|
||||
|
||||
|
@ -1633,7 +1606,7 @@ public:
|
|||
CBotString GetName();
|
||||
CBotCallMethode* Next();
|
||||
void AddNext(CBotCallMethode* p);
|
||||
|
||||
|
||||
};
|
||||
|
||||
// a list of parameters
|
||||
|
@ -1730,4 +1703,3 @@ public:
|
|||
bool GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack)
|
|||
return pStack->Return(NULL, pStk);
|
||||
}
|
||||
|
||||
// if we are not dealing with an operation + or -
|
||||
// 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);
|
||||
|
@ -141,4 +141,3 @@ bool CBotAddExpr::Execute(CBotStack* &pStack)
|
|||
return pStack->Return(pStk1); // transmits the result
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, bool bIntrinsic)
|
|||
|
||||
CBotClass::~CBotClass()
|
||||
{
|
||||
// removes the list of class
|
||||
// removes the list of class
|
||||
if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext;
|
||||
else m_ExClass = m_ExNext;
|
||||
|
||||
|
@ -106,7 +106,7 @@ bool CBotClass::Lock(CBotProgram* p)
|
|||
m_ProgInLock[0] = p;
|
||||
return true;
|
||||
}
|
||||
if ( p == m_ProgInLock[0] )
|
||||
if ( p == m_ProgInLock[0] )
|
||||
{
|
||||
m_cptOne++;
|
||||
m_cptLock--; // has already been counted
|
||||
|
@ -156,14 +156,14 @@ void CBotClass::FreeLock(CBotProgram* p)
|
|||
|
||||
while ( pClass != NULL )
|
||||
{
|
||||
if ( p == pClass->m_ProgInLock[0] )
|
||||
if ( p == pClass->m_ProgInLock[0] )
|
||||
{
|
||||
pClass->m_cptLock -= pClass->m_cptOne;
|
||||
pClass->m_cptOne = 0;
|
||||
}
|
||||
|
||||
for ( int j = 1; j < 5 ; j++ )
|
||||
if ( p == pClass->m_ProgInLock[j] )
|
||||
if ( p == pClass->m_ProgInLock[j] )
|
||||
pClass->m_cptLock--;
|
||||
|
||||
pClass = pClass->m_ExNext;
|
||||
|
@ -291,8 +291,8 @@ CBotClass* CBotClass::Find(const char* name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool CBotClass::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
bool CBotClass::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
|
||||
{
|
||||
// stores pointers to the two functions
|
||||
|
@ -313,7 +313,7 @@ bool CBotClass::AddFunction(const char* name,
|
|||
}
|
||||
|
||||
p = new CBotCallMethode(name, rExec, rCompile);
|
||||
|
||||
|
||||
if (m_pCalls == NULL) m_pCalls = p;
|
||||
else m_pCalls->AddNext(p); // added to the list
|
||||
|
||||
|
@ -329,8 +329,8 @@ bool CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) )
|
|||
// compiles a method associated with an instance of class
|
||||
// the method can be declared by the user or AddFunction
|
||||
|
||||
CBotTypResult CBotClass::CompileMethode(const char* name,
|
||||
CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotTypResult CBotClass::CompileMethode(const char* name,
|
||||
CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotCStack* pStack, long& nIdent)
|
||||
{
|
||||
nIdent = 0; // forget the previous one if necessary
|
||||
|
@ -350,8 +350,8 @@ CBotTypResult CBotClass::CompileMethode(const char* name,
|
|||
|
||||
// executes a method
|
||||
|
||||
bool CBotClass::ExecuteMethode(long& nIdent, const char* name,
|
||||
CBotVar* pThis, CBotVar** ppParams,
|
||||
bool CBotClass::ExecuteMethode(long& nIdent, const char* name,
|
||||
CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotVar* &pResult, CBotStack* &pStack,
|
||||
CBotToken* pToken)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ bool CBotClass::RestoreStaticState(FILE* pf)
|
|||
if (!ReadString( pf, VarName )) return false;
|
||||
if ( pClass != NULL ) pVar = pClass->GetItem(VarName);
|
||||
|
||||
if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable
|
||||
if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable
|
||||
|
||||
if ( pVar != NULL ) pVar->Copy(pv);
|
||||
delete pv;
|
||||
|
@ -514,7 +514,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
delete inst; // is not type CBotInt
|
||||
p = vartoken; // returns to the variable name
|
||||
|
||||
// compiles declaration an array
|
||||
// compiles declaration an array
|
||||
|
||||
inst = static_cast<CBotClassInst*>(CBotInstArray::Compile( p, pStk, type ));
|
||||
|
||||
|
@ -595,7 +595,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
goto error;
|
||||
}
|
||||
// if ( !bIntrinsic ) var->SetPointer(pStk->GetVar()->GetPointer());
|
||||
if ( !bIntrinsic )
|
||||
if ( !bIntrinsic )
|
||||
{
|
||||
// does not use the result on the stack, to impose the class
|
||||
CBotVar* pvar = CBotVar::Create("", pClass);
|
||||
|
@ -608,7 +608,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
{
|
||||
// creates the object on the "job" (\TODO "tas")
|
||||
// with a pointer to the object
|
||||
if ( !bIntrinsic )
|
||||
if ( !bIntrinsic )
|
||||
{
|
||||
CBotVar* pvar = CBotVar::Create("", pClass);
|
||||
var->SetPointer( pvar ); // variable already declared instance pointer
|
||||
|
@ -617,14 +617,14 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
var->SetInit(2); // marks the pointer as init
|
||||
}
|
||||
suite:
|
||||
if (IsOfType(p, ID_COMMA)) // several chained definitions
|
||||
if (IsOfType(p, ID_COMMA)) // several chained definitions
|
||||
{
|
||||
if ( NULL != ( inst->m_next = CBotClassInst::Compile(p, pStk, pClass) )) // compiles the following
|
||||
{
|
||||
return pStack->Return(inst, pStk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsOfType(p, ID_SEP)) // complete instruction
|
||||
{
|
||||
return pStack->Return(inst, pStk);
|
||||
|
@ -684,7 +684,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
|||
{
|
||||
// evaluates the expression for the assignment
|
||||
if (!m_expr->Execute(pile)) return false;
|
||||
|
||||
|
||||
if ( bIntrincic )
|
||||
{
|
||||
CBotVar* pv = pile->GetVar();
|
||||
|
@ -750,8 +750,8 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
|||
// creates a variable for the result
|
||||
CBotVar* pResult = NULL; // constructor still void
|
||||
|
||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||
pThis, ppVars,
|
||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||
pThis, ppVars,
|
||||
pResult, pile2, GetToken())) return false; // interrupt
|
||||
|
||||
pThis->SetInit(true);
|
||||
|
|
|
@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
}
|
||||
|
||||
|
||||
// perform the operation
|
||||
// perform the operation
|
||||
|
||||
bool CBotCompExpr::Execute(CBotStack* &pStack)
|
||||
{
|
||||
|
|
|
@ -93,22 +93,22 @@ public:
|
|||
CBotTypResult(int type);
|
||||
// for simple types (CBotTypInt à CBotTypString)
|
||||
|
||||
|
||||
|
||||
CBotTypResult(int type, const char* name);
|
||||
// for pointer types and intrinsic classes
|
||||
|
||||
|
||||
CBotTypResult(int type, CBotClass* pClass);
|
||||
// for the instance of a class
|
||||
|
||||
|
||||
CBotTypResult(int type, CBotTypResult elem);
|
||||
// for arrays of variables
|
||||
|
||||
|
||||
CBotTypResult(const CBotTypResult& typ);
|
||||
// for assignments
|
||||
|
||||
|
||||
CBotTypResult();
|
||||
// for default
|
||||
|
||||
|
||||
~CBotTypResult();
|
||||
|
||||
int GetType(int mode = 0) const;
|
||||
|
@ -147,7 +147,7 @@ private:
|
|||
CBotClass* m_pClass; // for the derivatives of class
|
||||
int m_limite; // limits of tables
|
||||
friend class CBotVarClass;
|
||||
friend class CBotVarPointer;
|
||||
friend class CBotVarPointer;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// as part of MFC CString not used here.
|
||||
//
|
||||
// ( all functions are not implemented yet )
|
||||
|
@ -451,12 +451,12 @@ public:
|
|||
|
||||
static
|
||||
void SetTimer(int n);
|
||||
// defines the number of steps (parts of instructions) to done
|
||||
// defines the number of steps (parts of instructions) to done
|
||||
// in Run() before rendering hand "false" \TODO avant de rendre la main "false"
|
||||
|
||||
static
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
|
||||
// call this to add externally (**)
|
||||
// a new function used by the program CBoT
|
||||
|
@ -472,8 +472,8 @@ public:
|
|||
// restores the state of execution from file
|
||||
// the compiled program must obviously be the same
|
||||
|
||||
bool GetPosition(const char* name, int& start, int& stop,
|
||||
CBotGet modestart = GetPosExtern,
|
||||
bool GetPosition(const char* name, int& start, int& stop,
|
||||
CBotGet modestart = GetPosExtern,
|
||||
CBotGet modestop = GetPosBloc);
|
||||
// gives the position of a routine in the original text
|
||||
// the user can select the item to find from the beginning to the end
|
||||
|
@ -513,7 +513,7 @@ int cMean(CBotVar* &pVar, CBotString& ClassName)
|
|||
|
||||
while ( pVar != NULL )
|
||||
{
|
||||
if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number
|
||||
if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number
|
||||
pVar = pVar -> GetNext();
|
||||
}
|
||||
|
||||
|
@ -623,7 +623,7 @@ virtual ~CBotVar( ); // destructor
|
|||
void SetName(const char* name); // changes the name of the variable
|
||||
|
||||
int GetType(int mode = 0); // returns the base type (int) of the variable
|
||||
// TODO check it
|
||||
// TODO check it
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBotTypResult GetTypResult(int mode = 0); // returns the complete type of the variable
|
||||
|
@ -654,7 +654,7 @@ virtual ~CBotVar( ); // destructor
|
|||
CBotVar* GetItemRef(int nIdent); // idem à partir du n° ref
|
||||
// TODO ditto from ref no.
|
||||
virtual
|
||||
CBotVar* GetItem(int row, bool bGrow = false);
|
||||
CBotVar* GetItem(int row, bool bGrow = false);
|
||||
|
||||
virtual
|
||||
CBotVar* GetItemList(); // lists the elements
|
||||
|
@ -802,8 +802,8 @@ public:
|
|||
|
||||
~CBotClass( ); // destructor
|
||||
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
bool AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
|
||||
// this call allows to add as external (**)
|
||||
// new method used by the objects of this class
|
||||
|
@ -841,7 +841,7 @@ public:
|
|||
CBotVar* GetItem(const char* name); // one of the variables according to its name
|
||||
CBotVar* GetItemRef(int nIdent);
|
||||
|
||||
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotCStack* pStack, long& nIdent);
|
||||
|
||||
bool ExecuteMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken);
|
||||
|
@ -854,7 +854,7 @@ public:
|
|||
CBotClass* Compile1(CBotToken* &p, CBotCStack* pStack);
|
||||
|
||||
bool CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond);
|
||||
|
||||
|
||||
bool IsIntrinsic();
|
||||
void Purge();
|
||||
static
|
||||
|
@ -917,7 +917,7 @@ private:
|
|||
|
||||
int m_start; // position in the original text (program)
|
||||
int m_end; // the same for the end of the token
|
||||
|
||||
|
||||
/**
|
||||
* \brief Check whether given parameter is a keyword
|
||||
*/
|
||||
|
@ -979,11 +979,11 @@ public:
|
|||
CBotToken* GetPrev();
|
||||
|
||||
/**
|
||||
* \brief transforms the entire program
|
||||
* \brief transforms the entire program
|
||||
*/
|
||||
static
|
||||
CBotToken* CompileTokens(const char* p, int& error);
|
||||
|
||||
|
||||
/**
|
||||
* \brief releases the list
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@ CBotFunction::CBotFunction()
|
|||
m_Param = NULL; // empty parameter list
|
||||
m_Block = NULL; // the instruction block
|
||||
m_next = NULL; // functions can be chained
|
||||
m_bPublic = false; // function not public
|
||||
m_bPublic = false; // function not public
|
||||
m_bExtern = false; // function not extern
|
||||
m_nextpublic = NULL;
|
||||
m_prevpublic = NULL;
|
||||
|
@ -159,9 +159,9 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
|
|||
if ( pClass != NULL)
|
||||
{
|
||||
p = p->GetNext();
|
||||
return ArrayType(p, pile,
|
||||
pClass->IsIntrinsic() ?
|
||||
CBotTypResult( CBotTypIntrinsic, pClass ) :
|
||||
return ArrayType(p, pile,
|
||||
pClass->IsIntrinsic() ?
|
||||
CBotTypResult( CBotTypIntrinsic, pClass ) :
|
||||
CBotTypResult( CBotTypPointer, pClass ) );
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
|||
}
|
||||
}
|
||||
|
||||
// and compiles the following instruction block
|
||||
// and compiles the following instruction block
|
||||
func->m_openblk = p;
|
||||
func->m_Block = CBotBlock::Compile(p, pStk, false);
|
||||
func->m_closeblk = p->GetPrev();
|
||||
|
@ -288,7 +288,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
|||
{
|
||||
CBotFunction* func = new CBotFunction();
|
||||
func->m_nFuncIdent = CBotVar::NextUniqNum();
|
||||
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(p, true);
|
||||
|
||||
while (true)
|
||||
|
@ -334,7 +334,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
|||
func->m_Param = CBotDefParam::Compile( p, pStk );
|
||||
if (pStk->IsOk())
|
||||
{
|
||||
// looks if the function exists elsewhere
|
||||
// looks if the function exists elsewhere
|
||||
if (( pClass != NULL || !pStack->CheckCall(pp, func->m_Param)) &&
|
||||
( pClass == NULL || !pClass->CheckCall(pp, func->m_Param)) )
|
||||
{
|
||||
|
@ -350,7 +350,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
|||
if (type == ID_CLBLK) level--;
|
||||
}
|
||||
while (level > 0 && p != NULL);
|
||||
|
||||
|
||||
return pStack->ReturnFunc(func, pStk);
|
||||
}
|
||||
pStk->SetError(TX_OPENBLK, p);
|
||||
|
@ -528,7 +528,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
|||
pv = pv->GetNext();
|
||||
pw = ppVars[i++];
|
||||
}
|
||||
if ( pw != NULL )
|
||||
if ( pw != NULL )
|
||||
{
|
||||
if ( pFunc != NULL ) continue;
|
||||
if ( TypeOrError.Eq(TX_LOWPARAM) ) TypeOrError.SetType(TX_NUMPARAM);
|
||||
|
@ -583,7 +583,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
|||
pv = pv->GetNext();
|
||||
pw = ppVars[i++];
|
||||
}
|
||||
if ( pw != NULL )
|
||||
if ( pw != NULL )
|
||||
{
|
||||
if ( pFunc != NULL ) continue;
|
||||
if ( TypeOrError.Eq(TX_LOWPARAM) ) TypeOrError.SetType(TX_NUMPARAM);
|
||||
|
@ -630,7 +630,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
|
|||
{
|
||||
CBotTypResult type;
|
||||
CBotFunction* pt = NULL;
|
||||
|
||||
|
||||
pt = FindLocalOrPublic(nIdent, name, ppVars, type);
|
||||
|
||||
if ( pt != NULL )
|
||||
|
@ -754,7 +754,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
|
|||
|
||||
|
||||
|
||||
// makes call of a method
|
||||
// makes call of a method
|
||||
// note: this is already on the stack, the pointer pThis is just to simplify
|
||||
|
||||
int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
|
||||
|
@ -951,7 +951,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if (IsOfType(p, ID_OPENPAR))
|
||||
{
|
||||
CBotDefParam* list = NULL;
|
||||
|
||||
|
||||
while (!IsOfType(p, ID_CLOSEPAR))
|
||||
{
|
||||
CBotDefParam* param = new CBotDefParam();
|
||||
|
@ -1090,7 +1090,7 @@ CBotDefParam* CBotDefParam::GetNext()
|
|||
CBotString CBotDefParam::GetParamString()
|
||||
{
|
||||
CBotString param;
|
||||
|
||||
|
||||
param = m_typename;
|
||||
param += ' ';
|
||||
|
||||
|
@ -1136,7 +1136,7 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if ( pStack->IsOk() )
|
||||
{
|
||||
CBotTypResult retType = pStack->GetTypResult(2);
|
||||
if (TypeCompatible(retType, type, ID_ASS))
|
||||
if (TypeCompatible(retType, type, ID_ASS))
|
||||
{
|
||||
if ( IsOfType( p, ID_SEP ) )
|
||||
return inst;
|
||||
|
@ -1202,7 +1202,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
int i = 0;
|
||||
|
||||
CBotToken* pp = p;
|
||||
CBotToken* pp = p;
|
||||
p = p->GetNext();
|
||||
|
||||
pStack->SetStartError(p->GetStart());
|
||||
|
@ -1367,7 +1367,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
|||
pStack->SetError(TX_NOPUBLIC, p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if ( !IsOfType(p, ID_CLASS) ) return NULL;
|
||||
|
||||
CBotString name = p->GetString();
|
||||
|
@ -1443,7 +1443,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
return false;
|
||||
}
|
||||
|
||||
while (pStack->IsOk())
|
||||
while (pStack->IsOk())
|
||||
{
|
||||
CBotToken* pp = p;
|
||||
IsOfType(p, ID_NOT); // skips ~ eventual (destructor)
|
||||
|
@ -1484,7 +1484,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
if ( !bSecond )
|
||||
{
|
||||
p = pBase;
|
||||
CBotFunction* f =
|
||||
CBotFunction* f =
|
||||
CBotFunction::Compile1(p, pStack, this);
|
||||
|
||||
if ( f == NULL ) return false;
|
||||
|
@ -1497,7 +1497,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
// return a method precompiled in pass 1
|
||||
CBotFunction* pf = m_pMethod;
|
||||
CBotFunction* prev = NULL;
|
||||
while ( pf != NULL )
|
||||
while ( pf != NULL )
|
||||
{
|
||||
if (pf->GetName() == pp->GetString()) break;
|
||||
prev = pf;
|
||||
|
@ -1541,7 +1541,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
|
||||
// compiles a method
|
||||
p = pBase;
|
||||
CBotFunction* f =
|
||||
CBotFunction* f =
|
||||
CBotFunction::Compile(p, pile, NULL/*, false*/);
|
||||
|
||||
if ( f != NULL )
|
||||
|
@ -1646,3 +1646,4 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
pStack->SetError(TX_ENDOF, p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ bool CBotIf :: Execute(CBotStack* &pj)
|
|||
// passes into the second state
|
||||
if (!pile->SetState(1)) return false; // ready for further
|
||||
}
|
||||
|
||||
|
||||
// second state, evaluates the associated instructions
|
||||
// the result of the condition is on the stack
|
||||
|
||||
|
@ -143,7 +143,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
|
|||
m_Condition->RestoreState(pile, bMain); // interrupted here!
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// second state, evaluates the associated instructions
|
||||
// the result of the condition is on the stack
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
{
|
||||
if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
|
||||
|
||||
if ( p->GetType() == ID_CLASS ||
|
||||
if ( p->GetType() == ID_CLASS ||
|
||||
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
|
||||
{
|
||||
CBotClass* nxt = CBotClass::Compile1(p, pStack);
|
||||
|
@ -113,7 +113,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
}
|
||||
if ( !pStack->IsOk() )
|
||||
{
|
||||
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||
delete m_Prog;
|
||||
m_Prog = NULL;
|
||||
delete pBaseToken;
|
||||
|
@ -129,7 +129,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
{
|
||||
if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
|
||||
|
||||
if ( p->GetType() == ID_CLASS ||
|
||||
if ( p->GetType() == ID_CLASS ||
|
||||
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
|
||||
{
|
||||
m_bCompileClass = true;
|
||||
|
@ -150,7 +150,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
|
||||
if ( !pStack->IsOk() )
|
||||
{
|
||||
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||
delete m_Prog;
|
||||
m_Prog = NULL;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ bool CBotProgram::Run(void* pUser, int timer)
|
|||
#if STACKRUN
|
||||
// resumes execution on the top of the stack
|
||||
ok = m_pStack->Execute();
|
||||
if ( ok )
|
||||
if ( ok )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CBotVar* ppVar[3];
|
||||
|
@ -354,8 +354,8 @@ CBotFunction* CBotProgram::GetFunctions()
|
|||
return m_Prog;
|
||||
}
|
||||
|
||||
bool CBotProgram::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool CBotProgram::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
// stores pointers to the two functions
|
||||
|
@ -369,7 +369,7 @@ bool WriteWord(FILE* pf, unsigned short w)
|
|||
|
||||
lg = fwrite(&w, sizeof( unsigned short ), 1, pf );
|
||||
|
||||
return (lg == 1);
|
||||
return (lg == 1);
|
||||
}
|
||||
|
||||
bool ReadWord(FILE* pf, unsigned short& w)
|
||||
|
@ -387,7 +387,7 @@ bool WriteFloat(FILE* pf, float w)
|
|||
|
||||
lg = fwrite(&w, sizeof( float ), 1, pf );
|
||||
|
||||
return (lg == 1);
|
||||
return (lg == 1);
|
||||
}
|
||||
|
||||
bool ReadFloat(FILE* pf, float& w)
|
||||
|
@ -405,7 +405,7 @@ bool WriteLong(FILE* pf, long w)
|
|||
|
||||
lg = fwrite(&w, sizeof( long ), 1, pf );
|
||||
|
||||
return (lg == 1);
|
||||
return (lg == 1);
|
||||
}
|
||||
|
||||
bool ReadLong(FILE* pf, long& w)
|
||||
|
@ -425,7 +425,7 @@ bool WriteString(FILE* pf, CBotString s)
|
|||
if (!WriteWord(pf, lg1)) return false;
|
||||
|
||||
lg2 = fwrite(s, 1, lg1, pf );
|
||||
return (lg1 == lg2);
|
||||
return (lg1 == lg2);
|
||||
}
|
||||
|
||||
bool ReadString(FILE* pf, CBotString& s)
|
||||
|
@ -510,7 +510,7 @@ bool CBotProgram::SaveState(FILE* pf)
|
|||
if (!WriteString( pf, m_pRun->GetName() )) return false;
|
||||
if (!m_pStack->SaveState(pf)) return false;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (!WriteWord( pf, 0)) return false;
|
||||
}
|
||||
|
@ -560,9 +560,9 @@ int CBotProgram::GetVersion()
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBotCall* CBotCall::m_ListCalls = NULL;
|
||||
|
||||
CBotCall::CBotCall(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
|
||||
CBotCall::CBotCall(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -583,8 +583,8 @@ void CBotCall::Free()
|
|||
delete CBotCall::m_ListCalls;
|
||||
}
|
||||
|
||||
bool CBotCall::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool CBotCall::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
CBotCall* p = m_ListCalls;
|
||||
|
@ -608,7 +608,7 @@ bool CBotCall::AddFunction(const char* name,
|
|||
}
|
||||
|
||||
pp = new CBotCall(name, rExec, rCompile);
|
||||
|
||||
|
||||
if (p) p->m_next = pp;
|
||||
else m_ListCalls = pp;
|
||||
|
||||
|
@ -658,7 +658,7 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack*
|
|||
CBotVar* pVar2 = pVar;
|
||||
CBotTypResult r = pt->m_rComp(pVar2, m_pUser);
|
||||
int ret = r.GetType();
|
||||
|
||||
|
||||
// if a class is returned, it is actually a pointer
|
||||
if ( ret == CBotTypClass ) r.SetType( ret = CBotTypPointer );
|
||||
|
||||
|
@ -859,8 +859,8 @@ bool CBotCall::Run(CBotStack* pStack)
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBotCallMethode::CBotCallMethode(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotCallMethode::CBotCallMethode(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -879,7 +879,7 @@ CBotCallMethode::~CBotCallMethode()
|
|||
// is acceptable by a call procedure name
|
||||
// and given parameters
|
||||
|
||||
CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
|
||||
CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
|
||||
CBotVar** ppVar, CBotCStack* pStack,
|
||||
long& nIdent)
|
||||
{
|
||||
|
@ -1008,7 +1008,7 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
|||
|
||||
while ( pVar != NULL )
|
||||
{
|
||||
i++;
|
||||
i++;
|
||||
pVar = pVar->GetNext();
|
||||
}
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ void CBotProgram::Init()
|
|||
|
||||
void CBotProgram::Free()
|
||||
{
|
||||
CBotToken::Free() ;
|
||||
CBotToken::Free() ;
|
||||
CBotCall ::Free() ;
|
||||
CBotClass::Free() ;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ CBotStack* CBotStack::FirstStack()
|
|||
pp->m_bOver = true;
|
||||
pp ++;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
int n = 1;
|
||||
pp = p;
|
||||
for ( i = 0 ; i< MAXSTACK+10 ; i++ )
|
||||
|
@ -120,7 +120,7 @@ void CBotStack::Delete()
|
|||
m_index = n;
|
||||
#endif
|
||||
|
||||
if ( p == NULL )
|
||||
if ( p == NULL )
|
||||
free( this );
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ void CBotStack::Delete()
|
|||
// routine improved
|
||||
CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
|
||||
{
|
||||
if (m_next != NULL)
|
||||
if (m_next != NULL)
|
||||
{
|
||||
return m_next; // included in an existing stack
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
|
|||
|
||||
CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
|
||||
{
|
||||
if (m_next != NULL)
|
||||
if (m_next != NULL)
|
||||
{
|
||||
if ( m_next == EOX )
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
|
|||
|
||||
CBotStack* CBotStack::AddStack2(bool bBlock)
|
||||
{
|
||||
if (m_next2 != NULL)
|
||||
if (m_next2 != NULL)
|
||||
{
|
||||
m_next2->m_prog = m_prog; // special avoids RestoreStack2
|
||||
return m_next2; // included in an existing stack
|
||||
|
@ -251,8 +251,8 @@ CBotStack::CBotStack(CBotStack* ppapa)
|
|||
if (ppapa == NULL) m_timer = m_initimer; // sets the timer at the beginning
|
||||
|
||||
m_listVar = NULL;
|
||||
m_bDontDelete = false;
|
||||
|
||||
m_bDontDelete = false;
|
||||
|
||||
m_var = NULL;
|
||||
m_prog = NULL;
|
||||
m_instr = NULL;
|
||||
|
@ -275,7 +275,7 @@ CBotStack::~CBotStack()
|
|||
// \TODO routine has/to optimize
|
||||
CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
|
||||
{
|
||||
if (m_next != NULL)
|
||||
if (m_next != NULL)
|
||||
{
|
||||
return m_next; // included in an existing stack
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
|
|||
|
||||
CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
|
||||
{
|
||||
if (m_next != NULL)
|
||||
if (m_next != NULL)
|
||||
{
|
||||
if ( m_next == EOX )
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
|
|||
|
||||
CBotStack* CBotStack::AddStack2(bool bBlock)
|
||||
{
|
||||
if (m_next2 != NULL)
|
||||
if (m_next2 != NULL)
|
||||
{
|
||||
m_next2->m_prog = m_prog; // special avoids RestoreStack2
|
||||
return m_next2; // included in an existing stack
|
||||
|
@ -362,7 +362,7 @@ void CBotStack::Reset(void* pUser)
|
|||
|
||||
CBotStack* CBotStack::RestoreStack(CBotInstr* instr)
|
||||
{
|
||||
if (m_next != NULL)
|
||||
if (m_next != NULL)
|
||||
{
|
||||
m_next->m_instr = instr; // reset (if recovery after )
|
||||
m_next->m_prog = m_prog;
|
||||
|
@ -480,7 +480,7 @@ CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
|
|||
{
|
||||
if (pp->GetName() == name)
|
||||
{
|
||||
if ( bUpdate )
|
||||
if ( bUpdate )
|
||||
pp->Maj(m_pUser, false);
|
||||
|
||||
return pp;
|
||||
|
@ -521,7 +521,7 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
|
|||
{
|
||||
if (pp->GetUniqNum() == ident)
|
||||
{
|
||||
if ( bUpdate )
|
||||
if ( bUpdate )
|
||||
pp->Maj(m_pUser, false);
|
||||
|
||||
return pp;
|
||||
|
@ -552,7 +552,7 @@ CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate)
|
|||
return pCopy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CBotStack::SetState(int n, int limite)
|
||||
{
|
||||
m_state = n;
|
||||
|
@ -609,7 +609,7 @@ bool CBotStack::Execute()
|
|||
while (p != NULL)
|
||||
{
|
||||
if ( p->m_next2 != NULL ) break;
|
||||
if ( p->m_call != NULL )
|
||||
if ( p->m_call != NULL )
|
||||
{
|
||||
instr = p->m_call;
|
||||
pile = p->m_prev ;
|
||||
|
@ -684,7 +684,7 @@ void CBotStack::AddVar(CBotVar* pVar)
|
|||
while (p != NULL && p->m_bBlock == 0) p = p->m_prev;
|
||||
|
||||
if ( p == NULL ) return;
|
||||
|
||||
|
||||
/// p->m_bDontDelete = bDontDelete;
|
||||
|
||||
CBotVar** pp = &p->m_listVar;
|
||||
|
@ -787,7 +787,7 @@ void CBotStack::GetRunPos(const char* &FunctionName, int &start, int &end)
|
|||
{
|
||||
if ( p->m_instr != NULL ) instr = p->m_instr;
|
||||
if ( p->m_bFunc == 1 ) funct = p->m_instr;
|
||||
if ( p->m_next->m_prog != prog ) break ;
|
||||
if ( p->m_next->m_prog != prog ) break ;
|
||||
|
||||
if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ;
|
||||
else p = p->m_next;
|
||||
|
@ -818,7 +818,7 @@ CBotVar* CBotStack::GetStackVars(const char* &FunctionName, int level)
|
|||
|
||||
while (p->m_next != NULL)
|
||||
{
|
||||
if ( p->m_next->m_prog != prog ) break ;
|
||||
if ( p->m_next->m_prog != prog ) break ;
|
||||
|
||||
if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ;
|
||||
else p = p->m_next;
|
||||
|
@ -848,7 +848,7 @@ CBotVar* CBotStack::GetStackVars(const char* &FunctionName, int level)
|
|||
|
||||
CBotToken* t = pp->m_instr->GetToken();
|
||||
FunctionName = t->GetString();
|
||||
|
||||
|
||||
return p->m_listVar;
|
||||
}
|
||||
|
||||
|
@ -872,8 +872,8 @@ bool CBotStack::SaveState(FILE* pf)
|
|||
if (!WriteWord(pf, m_state)) return false; // in what state?
|
||||
if (!WriteWord(pf, 0)) return false; // by compatibility m_bDontDelete
|
||||
if (!WriteWord(pf, m_step)) return false; // in what state?
|
||||
|
||||
|
||||
|
||||
|
||||
if (!SaveVar(pf, m_var)) return false; // current result
|
||||
if (!SaveVar(pf, m_listVar)) return false; // local variables
|
||||
|
||||
|
@ -921,7 +921,7 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
|
|||
|
||||
|
||||
bool CBotVar::Save0State(FILE* pf)
|
||||
{
|
||||
{
|
||||
if (!WriteWord(pf, 100+m_mPrivate))return false; // private variable?
|
||||
if (!WriteWord(pf, m_bStatic))return false; // static variable?
|
||||
if (!WriteWord(pf, m_type.GetType()))return false; // saves the type (always non-zero)
|
||||
|
@ -930,11 +930,11 @@ bool CBotVar::Save0State(FILE* pf)
|
|||
}
|
||||
|
||||
bool CBotVarInt::Save0State(FILE* pf)
|
||||
{
|
||||
{
|
||||
if ( !m_defnum.IsEmpty() )
|
||||
{
|
||||
if(!WriteWord(pf, 200 )) return false; // special marker
|
||||
if(!WriteString(pf, m_defnum)) return false; // name of the value
|
||||
if(!WriteString(pf, m_defnum)) return false; // name of the value
|
||||
}
|
||||
|
||||
return CBotVar::Save0State(pf);
|
||||
|
@ -1051,7 +1051,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
if ( p != NULL )
|
||||
{
|
||||
delete pNew;
|
||||
pNew = p; // resume known element
|
||||
pNew = p; // resume known element
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1167,7 +1167,7 @@ CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
|
|||
|
||||
|
||||
CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
|
||||
{
|
||||
{
|
||||
if ( pfils == this ) return inst;
|
||||
|
||||
if (m_var != NULL) delete m_var; // value replaced?
|
||||
|
@ -1185,7 +1185,7 @@ CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
|
|||
}
|
||||
|
||||
CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
|
||||
{
|
||||
{
|
||||
if (m_var != NULL) delete m_var; // value replaced?
|
||||
m_var = pfils->m_var; // result transmitted
|
||||
pfils->m_var = NULL; // not to destroy the variable
|
||||
|
@ -1292,7 +1292,7 @@ bool CBotCStack::IsOk()
|
|||
return (m_error == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBotCStack::SetStartError( int pos )
|
||||
{
|
||||
if ( m_error != 0) return; // does not change existing error
|
||||
|
|
|
@ -54,7 +54,6 @@ const std::map<EID,const char *> CBotString::s_keywordString =
|
|||
{ID_STATIC, "static"},
|
||||
{ID_PROTECTED, "protected"},
|
||||
{ID_PRIVATE, "private"},
|
||||
{ID_REPEAT, "repeat"},
|
||||
{ID_DEBUGDD, "STARTDEBUGDD"},
|
||||
{ID_INT, "int"},
|
||||
{ID_FLOAT, "float"},
|
||||
|
@ -162,7 +161,7 @@ CBotString::CBotString(const CBotString& srcString)
|
|||
int CBotString::GetLength()
|
||||
{
|
||||
if (m_ptr == NULL) return 0;
|
||||
return strlen( m_ptr );
|
||||
return strlen( m_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,7 +336,7 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc)
|
|||
delete[] m_ptr;
|
||||
m_ptr = nullptr;
|
||||
|
||||
m_lg = stringSrc.m_lg;
|
||||
m_lg = stringSrc.m_lg;
|
||||
|
||||
if (m_lg > 0)
|
||||
{
|
||||
|
@ -374,7 +373,7 @@ const CBotString& CBotString::operator=(const char ch)
|
|||
{
|
||||
delete[] m_ptr;
|
||||
|
||||
m_lg = 1;
|
||||
m_lg = 1;
|
||||
|
||||
m_ptr = new char[2];
|
||||
m_ptr[0] = ch;
|
||||
|
@ -390,7 +389,7 @@ const CBotString& CBotString::operator=(const char* pString)
|
|||
|
||||
if (pString != nullptr)
|
||||
{
|
||||
m_lg = strlen(pString);
|
||||
m_lg = strlen(pString);
|
||||
|
||||
if (m_lg != 0)
|
||||
{
|
||||
|
@ -521,7 +520,7 @@ int CBotString::Compare(const char * lpsz) const
|
|||
char* p = m_ptr;
|
||||
if (lpsz == NULL) lpsz = emptyString;
|
||||
if (m_ptr == NULL) p = emptyString;
|
||||
return strcmp(p, lpsz); // wcscmp
|
||||
return strcmp(p, lpsz); // wcscmp
|
||||
}
|
||||
|
||||
const char * CBotString::MapIdToString(EID id)
|
||||
|
|
|
@ -248,17 +248,15 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, bool first)
|
|||
{
|
||||
while (c != 0 && !CharInList(c, nch))
|
||||
{
|
||||
mot += c;
|
||||
c = *(program++); // next character
|
||||
if ( c == '\\' )
|
||||
{
|
||||
c = *(program++); // next character
|
||||
if ( c == 'n' ) c = '\n';
|
||||
if ( c == 'r' ) c = '\r';
|
||||
if ( c == 't' ) c = '\t';
|
||||
mot += c;
|
||||
c = *(program++); // next character
|
||||
}
|
||||
mot += c;
|
||||
c = *(program++);
|
||||
}
|
||||
if ( c == '\"' )
|
||||
{
|
||||
|
@ -474,7 +472,7 @@ void CBotToken::LoadKeyWords()
|
|||
{
|
||||
CBotString s;
|
||||
int i, n = 0;
|
||||
|
||||
|
||||
i = TokenKeyWord; //start with keywords of the language
|
||||
while (s.LoadString(i))
|
||||
{
|
||||
|
|
|
@ -36,3 +36,4 @@
|
|||
|
||||
extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1);
|
||||
extern bool IsOfTypeList(CBotToken* &p, int type1, ...);
|
||||
|
||||
|
|
|
@ -63,10 +63,10 @@ CBotLogicExpr::~CBotLogicExpr()
|
|||
// acceptable type, operand
|
||||
// zero ends level \TODO précéance
|
||||
|
||||
static int ListOp[] =
|
||||
static int ListOp[] =
|
||||
{
|
||||
BOOLEEN, ID_LOGIC, 0,
|
||||
BOOLEEN, ID_TXT_OR,
|
||||
BOOLEEN, ID_TXT_OR,
|
||||
BOOLEEN, ID_LOG_OR, 0,
|
||||
BOOLEEN, ID_TXT_AND,
|
||||
BOOLEEN, ID_LOG_AND, 0,
|
||||
|
@ -76,7 +76,7 @@ static int ListOp[] =
|
|||
BOOLEEN|ENTIER|FLOTANT
|
||||
|CHAINE
|
||||
|POINTER
|
||||
|INSTANCE,ID_EQ,
|
||||
|INSTANCE,ID_EQ,
|
||||
BOOLEEN|ENTIER|FLOTANT
|
||||
|CHAINE
|
||||
|POINTER
|
||||
|
@ -90,8 +90,8 @@ static int ListOp[] =
|
|||
ENTIER, ID_ASR, 0,
|
||||
ENTIER|FLOTANT|CHAINE, ID_ADD,
|
||||
ENTIER|FLOTANT, ID_SUB, 0,
|
||||
ENTIER|FLOTANT, ID_MUL,
|
||||
ENTIER|FLOTANT, ID_DIV,
|
||||
ENTIER|FLOTANT, ID_MUL,
|
||||
ENTIER|FLOTANT, ID_DIV,
|
||||
ENTIER|FLOTANT, ID_MODULO, 0,
|
||||
ENTIER|FLOTANT, ID_POWER, 0,
|
||||
0,
|
||||
|
@ -194,7 +194,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
|||
if ( NULL != (inst->m_rightop = CBotTwoOpExpr::Compile( p, pStk, pOp )) )
|
||||
// expression (...) right
|
||||
{
|
||||
// there is an second operand acceptable
|
||||
// there is an second operand acceptable
|
||||
|
||||
type2 = pStk->GetTypResult(); // what kind of results?
|
||||
|
||||
|
@ -327,7 +327,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
}
|
||||
|
||||
|
||||
// requires a little more stack to avoid touching the result
|
||||
// requires a little more stack to avoid touching the result
|
||||
// of which is left on the stack, precisely
|
||||
|
||||
CBotStack* pStk2 = pStk1->AddStack(); // adds an item to the stack
|
||||
|
@ -566,3 +566,4 @@ void t(bool t)
|
|||
t ? 0 : "test";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -134,8 +134,8 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type
|
|||
m_LimExpr = NULL;
|
||||
m_pVar = NULL;
|
||||
m_type = type;
|
||||
if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody );
|
||||
else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass );
|
||||
if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody );
|
||||
else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass );
|
||||
// officel type for this object
|
||||
|
||||
m_pClass = NULL;
|
||||
|
@ -394,7 +394,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
|
|||
CBotVarClass* instance = new CBotVarClass(&name, type);
|
||||
CBotVarArray* array = new CBotVarArray(&name, type);
|
||||
array->SetPointer( instance );
|
||||
|
||||
|
||||
CBotVar* pv = array;
|
||||
while (type.Eq(CBotTypArrayBody))
|
||||
{
|
||||
|
@ -414,14 +414,14 @@ CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass)
|
|||
{
|
||||
CBotToken token( name, "" );
|
||||
CBotVar* pVar = Create( &token, type );
|
||||
|
||||
|
||||
if ( type == CBotTypPointer && pClass == NULL ) // pointer "null" ?
|
||||
return pVar;
|
||||
|
||||
if ( type == CBotTypClass || type == CBotTypPointer ||
|
||||
type == CBotTypIntrinsic )
|
||||
{
|
||||
if (pClass == NULL)
|
||||
if (pClass == NULL)
|
||||
{
|
||||
delete pVar;
|
||||
return NULL;
|
||||
|
@ -443,9 +443,9 @@ CBotTypResult CBotVar::GetTypResult(int mode)
|
|||
{
|
||||
CBotTypResult r = m_type;
|
||||
|
||||
if ( mode == 1 && m_type.Eq(CBotTypClass) )
|
||||
if ( mode == 1 && m_type.Eq(CBotTypClass) )
|
||||
r.SetType(CBotTypPointer);
|
||||
if ( mode == 2 && m_type.Eq(CBotTypClass) )
|
||||
if ( mode == 2 && m_type.Eq(CBotTypClass) )
|
||||
r.SetType(CBotTypIntrinsic);
|
||||
|
||||
return r;
|
||||
|
@ -453,9 +453,9 @@ CBotTypResult CBotVar::GetTypResult(int mode)
|
|||
|
||||
int CBotVar::GetType(int mode)
|
||||
{
|
||||
if ( mode == 1 && m_type.Eq(CBotTypClass) )
|
||||
if ( mode == 1 && m_type.Eq(CBotTypClass) )
|
||||
return CBotTypPointer;
|
||||
if ( mode == 2 && m_type.Eq(CBotTypClass) )
|
||||
if ( mode == 2 && m_type.Eq(CBotTypClass) )
|
||||
return CBotTypIntrinsic;
|
||||
return m_type.GetType();
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ void CBotVar::SetVal(CBotVar* var)
|
|||
ASM_TRAP();
|
||||
}
|
||||
|
||||
m_binit = var->m_binit; // copie l'état nan s'il y a
|
||||
m_binit = var->m_binit; // copie l'état nan s'il y a
|
||||
}
|
||||
|
||||
void CBotVar::SetStatic(bool bStatic)
|
||||
|
@ -1293,7 +1293,7 @@ void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right)
|
|||
|
||||
void CBotVarBoolean::Not()
|
||||
{
|
||||
m_val = m_val ? false : true ;
|
||||
m_val = m_val ? false : true ;
|
||||
}
|
||||
|
||||
bool CBotVarBoolean::Eq(CBotVar* left, CBotVar* right)
|
||||
|
@ -1468,7 +1468,7 @@ void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent)
|
|||
CBotInstr* p = pv->m_LimExpr; // the different formulas
|
||||
if ( p != NULL )
|
||||
{
|
||||
CBotStack* pile = CBotStack::FirstStack(); // an independent stack
|
||||
CBotStack* pile = CBotStack::FirstStack(); // an independent stack
|
||||
int n = 0;
|
||||
int max[100];
|
||||
|
||||
|
@ -1524,7 +1524,7 @@ CBotClass* CBotVarClass::GetClass()
|
|||
|
||||
void CBotVarClass::Maj(void* pUser, bool bContinu)
|
||||
{
|
||||
/* if (!bContinu && m_pMyThis != NULL)
|
||||
/* if (!bContinu && m_pMyThis != NULL)
|
||||
m_pMyThis->Maj(pUser, true);*/
|
||||
|
||||
// an update routine exist?
|
||||
|
@ -1671,7 +1671,7 @@ void CBotVarClass::IncrementUse()
|
|||
void CBotVarClass::DecrementUse()
|
||||
{
|
||||
m_CptUse--;
|
||||
if ( m_CptUse == 0 )
|
||||
if ( m_CptUse == 0 )
|
||||
{
|
||||
// if there is one, call the destructor
|
||||
// but only if a constructor had been called.
|
||||
|
@ -2025,7 +2025,7 @@ bool CBotVarPointer::Save1State(FILE* pf)
|
|||
|
||||
if (!WriteLong(pf, GetIdent())) return false; // the unique reference
|
||||
|
||||
// also saves the proceedings copies
|
||||
// also saves the proceedings copies
|
||||
return SaveVar(pf, GetPointer());
|
||||
}
|
||||
|
||||
|
@ -2082,7 +2082,7 @@ bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right)
|
|||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// management of results types
|
||||
// management of results types
|
||||
|
||||
|
||||
CBotTypResult::CBotTypResult(int type)
|
||||
|
@ -2164,7 +2164,7 @@ int CBotTypResult::GetType(int mode) const
|
|||
|
||||
if ( m_pClass == NULL ) ASM_TRAP();
|
||||
|
||||
|
||||
|
||||
if ( m_type == CBotTypArrayPointer )
|
||||
if ( m_pNext == NULL ) ASM_TRAP();
|
||||
#endif
|
||||
|
@ -2245,4 +2245,3 @@ CBotTypResult&
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,16 +112,16 @@ bool CBotWhile :: Execute(CBotStack* &pj)
|
|||
// the condition is true, pass in the second mode
|
||||
|
||||
if (!pile->SetState(1)) return false; // ready for further
|
||||
|
||||
|
||||
case 1:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL &&
|
||||
if ( m_Block != NULL &&
|
||||
!m_Block->Execute(pile) )
|
||||
{
|
||||
if (pile->IfContinue(0, 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() )
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ bool CBotWhile :: Execute(CBotStack* &pj)
|
|||
|
||||
// returns to the test again
|
||||
if (!pile->SetState(0, 0)) return false;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,163 +140,20 @@ void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
|
|||
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||
if ( pile == NULL ) return;
|
||||
|
||||
switch( pile->GetState() )
|
||||
switch( pile->GetState() )
|
||||
{ // there are two possible states (depending on recovery)
|
||||
case 0:
|
||||
// evaluates the condition
|
||||
m_Condition->RestoreState(pile, bMain);
|
||||
m_Condition->RestoreState(pile, bMain);
|
||||
return;
|
||||
|
||||
|
||||
case 1:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// compiles instruction "repeat"
|
||||
|
||||
CBotRepeat::CBotRepeat()
|
||||
{
|
||||
m_NbIter =
|
||||
m_Block = NULL; // NULL so that delete is not possible further
|
||||
name = "CBotRepeat"; // debug
|
||||
}
|
||||
|
||||
CBotRepeat::~CBotRepeat()
|
||||
{
|
||||
delete m_NbIter; // frees the condition
|
||||
delete m_Block; // frees the instruction block
|
||||
}
|
||||
|
||||
CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||
{
|
||||
CBotRepeat* inst = new CBotRepeat(); // 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_REPEAT)) return NULL; // should never happen
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp); // un petit bout de pile svp
|
||||
|
||||
if ( IsOfType(p, ID_OPENPAR ) )
|
||||
{
|
||||
CBotToken* ppp = p; // preserves the ^ token (starting position)
|
||||
if ( NULL != (inst->m_NbIter = CBotExpression::Compile( p, pStk )) )
|
||||
{
|
||||
if ( pStk->GetType() < CBotTypLong )
|
||||
{
|
||||
if ( IsOfType(p, ID_CLOSEPAR ) )
|
||||
{
|
||||
|
||||
IncLvl(inst->m_label);
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
DecLvl();
|
||||
|
||||
if ( pStk->IsOk() )
|
||||
{
|
||||
// the statement block is ok (it may be empty!
|
||||
|
||||
return pStack->Return(inst, pStk); // return an object to the application
|
||||
}
|
||||
}
|
||||
pStack->SetError(TX_CLOSEPAR, p->GetStart());
|
||||
}
|
||||
pStk->SetStartError(ppp->GetStart());
|
||||
pStk->SetError( TX_BADTYPE, p->GetStart() );
|
||||
}
|
||||
pStack->SetError(TX_ENDOF, p);
|
||||
}
|
||||
pStack->SetError(TX_OPENPAR, p->GetStart()); // missing parenthesis
|
||||
|
||||
delete inst; // error, frees up
|
||||
return pStack->Return(NULL, pStk); // no object, the error is on the stack
|
||||
}
|
||||
|
||||
// execution of intruction "repeat"
|
||||
|
||||
bool CBotRepeat :: 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 number of iterations
|
||||
if ( !m_NbIter->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
|
||||
int n;
|
||||
if ( !pile->IsOk() || ( n = pile->GetVal() ) < 1 )
|
||||
{
|
||||
return pj->Return(pile); // sends the results and releases the stack
|
||||
}
|
||||
|
||||
// puts the number of iterations +1 to the "state"
|
||||
|
||||
if (!pile->SetState(n+1)) return false; // ready for further
|
||||
continue; // continue as a result
|
||||
|
||||
case 1:
|
||||
// normal end of the loop
|
||||
return pj->Return(pile); // sends the results and releases the stack
|
||||
|
||||
default:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL &&
|
||||
!m_Block->Execute(pile) )
|
||||
{
|
||||
if (pile->IfContinue(pile->GetState()-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
|
||||
}
|
||||
|
||||
// returns to the test again
|
||||
if (!pile->SetState(pile->GetState()-1, 0)) return false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||
if ( pile == NULL ) return;
|
||||
|
||||
switch( pile->GetState() )
|
||||
{ // there are two possible states (depending on recovery)
|
||||
case 0:
|
||||
// evaluates the condition
|
||||
m_NbIter->RestoreState(pile, bMain);
|
||||
return;
|
||||
|
||||
case 1:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -374,13 +231,13 @@ bool CBotDo :: Execute(CBotStack* &pj)
|
|||
{ // there are two possible states (depending on recovery)
|
||||
case 0:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL &&
|
||||
if ( m_Block != NULL &&
|
||||
!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() )
|
||||
{
|
||||
|
@ -388,7 +245,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
|
|||
}
|
||||
|
||||
if (!pile->SetState(1)) return false; // ready for further
|
||||
|
||||
|
||||
case 1:
|
||||
// evaluates the condition
|
||||
if ( !m_Condition->Execute(pile) ) return false; // interrupted here ?
|
||||
|
@ -403,7 +260,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
|
|||
|
||||
// returns to instruction block to start
|
||||
if (!pile->SetState(0, 0)) return false;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +277,7 @@ void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
|
|||
// restores the assosiated statement's block
|
||||
if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain);
|
||||
return;
|
||||
|
||||
|
||||
case 1:
|
||||
// restores the condition
|
||||
m_Condition->RestoreState(pile, bMain);
|
||||
|
@ -445,9 +302,9 @@ CBotFor::CBotFor()
|
|||
|
||||
CBotFor::~CBotFor()
|
||||
{
|
||||
delete m_Init;
|
||||
delete m_Test;
|
||||
delete m_Incr;
|
||||
delete m_Init;
|
||||
delete m_Test;
|
||||
delete m_Incr;
|
||||
delete m_Block; // frees the instruction block
|
||||
}
|
||||
|
||||
|
@ -529,7 +386,7 @@ bool CBotFor :: Execute(CBotStack* &pj)
|
|||
if ( m_Init != NULL &&
|
||||
!m_Init->Execute(pile) ) return false; // interrupted here ?
|
||||
if (!pile->SetState(1)) return false; // ready for further
|
||||
|
||||
|
||||
case 1:
|
||||
// evaluates the condition
|
||||
if ( m_Test != NULL ) // no strings attached? -> True!
|
||||
|
@ -547,10 +404,10 @@ bool CBotFor :: Execute(CBotStack* &pj)
|
|||
|
||||
// la condition est vrai, passe à la suite
|
||||
if (!pile->SetState(2)) return false; // ready for further
|
||||
|
||||
|
||||
case 2:
|
||||
// evaluates the associated statement block
|
||||
if ( m_Block != NULL &&
|
||||
if ( m_Block != NULL &&
|
||||
!m_Block->Execute(pile) )
|
||||
{
|
||||
if (pile->IfContinue(3, m_label)) continue; // if continued, going on to incrementation
|
||||
|
@ -572,7 +429,7 @@ bool CBotFor :: Execute(CBotStack* &pj)
|
|||
|
||||
// returns to the test again
|
||||
if (!pile->SetState(1, 0)) return false; // returns to the test
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,7 +446,7 @@ void CBotFor :: RestoreState(CBotStack* &pj, bool bMain)
|
|||
// initialize
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, true); // interrupted here !
|
||||
return;
|
||||
|
||||
|
||||
case 1:
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // variables definitions
|
||||
|
||||
|
@ -686,7 +543,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
|
|||
{
|
||||
CBotStack* pile = pj;
|
||||
int state = 0x7000;
|
||||
|
||||
|
||||
if ( bMain )
|
||||
{
|
||||
pile = pj->RestoreStack();
|
||||
|
@ -758,7 +615,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
CBotInstr* i = CBotCase::Compile( p, pStk2 );
|
||||
if (i == NULL)
|
||||
{
|
||||
delete inst;
|
||||
delete inst;
|
||||
return pStack->Return(NULL, pStk2);
|
||||
}
|
||||
delete pStk2;
|
||||
|
@ -766,7 +623,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
else inst->m_Block->AddNext(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( inst->m_Block == NULL )
|
||||
{
|
||||
pStk->SetError(TX_NOCASE, p->GetStart());
|
||||
|
@ -790,7 +647,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
}
|
||||
}
|
||||
DecLvl();
|
||||
|
||||
|
||||
if ( inst->m_Block == NULL )
|
||||
{
|
||||
pStk->SetError(TX_NOCASE, p->GetStart());
|
||||
|
@ -817,7 +674,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
bool CBotSwitch :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile1 = pj->AddStack(this); // adds an item to the stack
|
||||
CBotStack* pile1 = pj->AddStack(this); // adds an item to the stack
|
||||
// if ( pile1 == EOX ) return true;
|
||||
|
||||
CBotInstr* p = m_Block; // first expression
|
||||
|
@ -866,7 +723,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
|
|||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
CBotStack* pile1 = pj->RestoreStack(this); // adds an item to the stack
|
||||
CBotStack* pile1 = pj->RestoreStack(this); // adds an item to the stack
|
||||
if ( pile1 == NULL ) return;
|
||||
|
||||
CBotInstr* p = m_Block; // first expression
|
||||
|
@ -1055,7 +912,7 @@ CBotTry::~CBotTry()
|
|||
delete m_ListCatch; // frees the list
|
||||
delete m_Block; // frees the instruction block
|
||||
delete m_FinalInst;
|
||||
}
|
||||
}
|
||||
|
||||
CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||
{
|
||||
|
@ -1069,7 +926,7 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk );
|
||||
CBotCatch** pn = &inst->m_ListCatch;
|
||||
|
||||
|
||||
while (pStk->IsOk() && p->GetType() == ID_CATCH)
|
||||
{
|
||||
CBotCatch* i = CBotCatch::Compile(p, pStk);
|
||||
|
@ -1154,7 +1011,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
|||
if ( !pc->Execute(pile2) ) return false; // performs the operation
|
||||
if ( m_FinalInst == NULL )
|
||||
return pj->Return(pile2); // ends the try
|
||||
|
||||
|
||||
pile1->SetState(-2); // passes final
|
||||
break;
|
||||
}
|
||||
|
@ -1162,13 +1019,13 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
|||
}
|
||||
pc = pc->m_next;
|
||||
}
|
||||
if ( m_FinalInst != NULL &&
|
||||
if ( m_FinalInst != NULL &&
|
||||
pile1->GetState() > 0 && val != 0 ) pile1->SetState(-1);// if stop then made the final
|
||||
|
||||
if (pile1->GetState() <= -1)
|
||||
{
|
||||
// pile0->SetState(1);
|
||||
|
||||
|
||||
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false;
|
||||
if (!pile2->IsOk()) return pj->Return(pile2); // keep this exception
|
||||
pile2->SetError(pile1->GetState()==-1 ? val : 0); // gives the initial error
|
||||
|
@ -1319,7 +1176,7 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
|||
var->SetValInt( pile->GetVal() == val );
|
||||
pile->SetVar(var); // calls on the stack
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ CBotVar.cpp
|
|||
CBotWhile.cpp
|
||||
)
|
||||
|
||||
if(${CBOT_STATIC})
|
||||
if(CBOT_STATIC)
|
||||
add_library(CBot STATIC ${SOURCES})
|
||||
else()
|
||||
add_library(CBot SHARED ${SOURCES})
|
||||
|
@ -21,3 +21,4 @@ else()
|
|||
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
||||
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||
endif()
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD!
|
|||
// gets the filename as a parameter
|
||||
|
||||
// execution
|
||||
bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
CBotString mode;
|
||||
|
||||
|
@ -239,7 +239,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
|||
return CBotTypResult(CBotTypBoolean); //DR
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE :: close method
|
||||
|
||||
// execution
|
||||
|
@ -291,7 +291,7 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
|||
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
|
||||
|
||||
FILE* pFile= (FILE*)pVar->GetValInt();
|
||||
|
||||
|
||||
int res = fputs(param+CBotString("\n"), pFile);
|
||||
|
||||
// on error throws an exception
|
||||
|
|
|
@ -184,10 +184,10 @@ bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
|||
if ( pVar->GetNext() != NULL )
|
||||
{
|
||||
pVar = pVar->GetNext();
|
||||
|
||||
|
||||
// which must be a number
|
||||
if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
|
||||
|
||||
|
||||
// retrieves this number
|
||||
int l = pVar->GetValInt();
|
||||
|
||||
|
@ -231,7 +231,7 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser )
|
|||
// third parameter optional
|
||||
if ( pVar->GetNext() != NULL )
|
||||
{
|
||||
|
||||
|
||||
pVar = pVar->GetNext();
|
||||
// which must be a number
|
||||
if ( pVar->GetType() > CBotTypDouble )
|
||||
|
@ -434,3 +434,4 @@ void InitStringFunctions()
|
|||
CBotProgram::AddFunction("strupper", rStrUpper, cStrStr );
|
||||
CBotProgram::AddFunction("strlower", rStrLower, cStrStr );
|
||||
}
|
||||
|
||||
|
|
|
@ -39,3 +39,4 @@ the object being created with CBotVar :: Create (name, pClasse)
|
|||
not destroy the object when there imédiatement pointers
|
||||
but marked as virtually destroyed
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ enum EID
|
|||
ID_STATIC,
|
||||
ID_PROTECTED,
|
||||
ID_PRIVATE,
|
||||
ID_REPEAT,
|
||||
ID_DEBUGDD,
|
||||
ID_INT,
|
||||
ID_FLOAT,
|
||||
|
@ -177,3 +176,4 @@ enum EID
|
|||
#define TX_ERRWRITE 6015
|
||||
|
||||
#define TX_MAX 6016
|
||||
|
||||
|
|
|
@ -8,12 +8,8 @@ set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
|
|||
|
||||
add_subdirectory(CBot)
|
||||
|
||||
add_subdirectory(tools)
|
||||
|
||||
add_subdirectory(po)
|
||||
|
||||
if(${DESKTOP})
|
||||
add_subdirectory(desktop)
|
||||
if(TOOLS)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -21,20 +17,20 @@ endif()
|
|||
set(OPTIONAL_LIBS "")
|
||||
set(OPTIONAL_INCLUDES "")
|
||||
|
||||
if (${OPENAL_SOUND})
|
||||
if(OPENAL_SOUND)
|
||||
set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
|
||||
set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# Additional libraries per platform
|
||||
if (${MXE}) # MXE requires special treatment
|
||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||
elseif (${PLATFORM_WINDOWS})
|
||||
if(MXE) # MXE requires special treatment
|
||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||
elseif(PLATFORM_WINDOWS)
|
||||
# because it isn't included in standard linking libraries
|
||||
set(PLATFORM_LIBS "-lintl")
|
||||
elseif(${PLATFORM_LINUX})
|
||||
elseif(PLATFORM_LINUX)
|
||||
# for clock_gettime
|
||||
set(PLATFORM_LIBS "-lrt")
|
||||
set(PLATFORM_LIBS "-lrt -lX11")
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -43,7 +39,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h
|
|||
|
||||
set(OPENAL_SRC "")
|
||||
|
||||
if (${OPENAL_SOUND})
|
||||
if(OPENAL_SOUND)
|
||||
set(OPENAL_SRC
|
||||
sound/oalsound/alsound.cpp
|
||||
sound/oalsound/buffer.cpp
|
||||
|
@ -52,9 +48,9 @@ if (${OPENAL_SOUND})
|
|||
endif()
|
||||
|
||||
# Platform-dependent implementation of system.h
|
||||
if (${PLATFORM_WINDOWS})
|
||||
if(PLATFORM_WINDOWS)
|
||||
set(SYSTEM_CPP_MODULE "system_windows.cpp")
|
||||
elseif(${PLATFORM_LINUX})
|
||||
elseif(PLATFORM_LINUX)
|
||||
set(SYSTEM_CPP_MODULE "system_linux.cpp")
|
||||
else()
|
||||
set(SYSTEM_CPP_MODULE "system_other.cpp")
|
||||
|
@ -120,6 +116,7 @@ object/mainmovie.cpp
|
|||
object/motion/motion.cpp
|
||||
object/motion/motionant.cpp
|
||||
object/motion/motionbee.cpp
|
||||
object/motion/motiondummy.cpp
|
||||
object/motion/motionhuman.cpp
|
||||
object/motion/motionmother.cpp
|
||||
object/motion/motionspider.cpp
|
||||
|
@ -128,6 +125,7 @@ object/motion/motionvehicle.cpp
|
|||
object/motion/motionworm.cpp
|
||||
object/object.cpp
|
||||
object/robotmain.cpp
|
||||
object/objman.cpp
|
||||
object/task/task.cpp
|
||||
object/task/taskadvance.cpp
|
||||
object/task/taskbuild.cpp
|
||||
|
@ -153,6 +151,7 @@ physics/physics.cpp
|
|||
script/cbottoken.cpp
|
||||
script/cmdtoken.cpp
|
||||
script/script.cpp
|
||||
sound/sound.cpp
|
||||
ui/button.cpp
|
||||
ui/check.cpp
|
||||
ui/color.cpp
|
||||
|
@ -185,6 +184,8 @@ ${OPENAL_SRC}
|
|||
|
||||
set(LIBS
|
||||
CBot
|
||||
clipboard
|
||||
localename
|
||||
${SDL_LIBRARY}
|
||||
${SDLIMAGE_LIBRARY}
|
||||
${SDLTTF_LIBRARY}
|
||||
|
@ -214,7 +215,9 @@ ${PNG_INCLUDE_DIRS}
|
|||
${GLEW_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${LIBSNDFILE_INCLUDE_DIR}
|
||||
${LOCALENAME_INCLUDE_DIR}
|
||||
${OPTIONAL_INCLUDE_DIRS}
|
||||
${CLIPBOARD_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
|
||||
|
@ -225,3 +228,4 @@ target_link_libraries(colobot ${LIBS})
|
|||
|
||||
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
* \dir src/app
|
||||
* Main class of the application and system functions
|
||||
*/
|
||||
|
||||
|
|
590
src/app/app.cpp
590
src/app/app.cpp
File diff suppressed because it is too large
Load Diff
111
src/app/app.h
111
src/app/app.h
|
@ -31,6 +31,8 @@
|
|||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/opengl/gldevice.h"
|
||||
|
||||
#include "object/objman.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -141,6 +143,15 @@ enum PerformanceCounter
|
|||
PCNT_MAX
|
||||
};
|
||||
|
||||
enum DebugMode
|
||||
{
|
||||
DEBUG_SYS_EVENTS = 1 << 0,
|
||||
DEBUG_APP_EVENTS = 1 << 1,
|
||||
DEBUG_EVENTS = DEBUG_SYS_EVENTS | DEBUG_APP_EVENTS,
|
||||
DEBUG_MODELS = 1 << 2,
|
||||
DEBUG_ALL = DEBUG_SYS_EVENTS | DEBUG_APP_EVENTS | DEBUG_MODELS
|
||||
};
|
||||
|
||||
struct ApplicationPrivate;
|
||||
|
||||
/**
|
||||
|
@ -207,20 +218,20 @@ public:
|
|||
//! Main event loop
|
||||
int Run();
|
||||
//! Returns the code to be returned at main() exit
|
||||
int GetExitCode();
|
||||
int GetExitCode() const;
|
||||
|
||||
//! Returns the message of error (set to something if exit code is not 0)
|
||||
const std::string& GetErrorMessage();
|
||||
const std::string& GetErrorMessage() const;
|
||||
|
||||
//! Cleans up before exit
|
||||
void Destroy();
|
||||
|
||||
//! Returns a list of possible video modes
|
||||
VideoQueryResult GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
|
||||
bool fullScreen, bool resizeable);
|
||||
bool fullScreen, bool resizeable) const;
|
||||
|
||||
//! Returns the current video mode
|
||||
Gfx::GLDeviceConfig GetVideoConfig();
|
||||
Gfx::GLDeviceConfig GetVideoConfig() const;
|
||||
|
||||
//! Change the video mode to given mode
|
||||
bool ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig);
|
||||
|
@ -230,35 +241,38 @@ public:
|
|||
//! Resumes animation
|
||||
void ResumeSimulation();
|
||||
//! Returns whether simulation is suspended
|
||||
bool GetSimulationSuspended();
|
||||
bool GetSimulationSuspended() const;
|
||||
|
||||
//! Resets time counters to account for time spent loading game
|
||||
void ResetTimeAfterLoading();
|
||||
|
||||
//@{
|
||||
//! Management of simulation speed
|
||||
void SetSimulationSpeed(float speed);
|
||||
float GetSimulationSpeed();
|
||||
float GetSimulationSpeed() const;
|
||||
//@}
|
||||
|
||||
//! Returns the absolute time counter [seconds]
|
||||
float GetAbsTime();
|
||||
float GetAbsTime() const;
|
||||
//! Returns the exact absolute time counter [nanoseconds]
|
||||
long long GetExactAbsTime();
|
||||
long long GetExactAbsTime() const;
|
||||
|
||||
//! Returns the exact absolute time counter disregarding speed setting [nanoseconds]
|
||||
long long GetRealAbsTime();
|
||||
long long GetRealAbsTime() const;
|
||||
|
||||
//! Returns the relative time since last update [seconds]
|
||||
float GetRelTime();
|
||||
float GetRelTime() const;
|
||||
//! Returns the exact realative time since last update [nanoseconds]
|
||||
long long GetExactRelTime();
|
||||
long long GetExactRelTime() const;
|
||||
|
||||
//! Returns the exact relative time since last update disregarding speed setting [nanoseconds]
|
||||
long long GetRealRelTime();
|
||||
long long GetRealRelTime() const;
|
||||
|
||||
//! Returns a list of available joystick devices
|
||||
std::vector<JoystickDevice> GetJoystickList();
|
||||
std::vector<JoystickDevice> GetJoystickList() const;
|
||||
|
||||
//! Returns info about the current joystick
|
||||
JoystickDevice GetJoystick();
|
||||
JoystickDevice GetJoystick() const;
|
||||
|
||||
//! Change the current joystick device
|
||||
bool ChangeJoystick(const JoystickDevice &newJoystick);
|
||||
|
@ -266,7 +280,7 @@ public:
|
|||
//! Management of joystick enable state
|
||||
//@{
|
||||
void SetJoystickEnabled(bool enable);
|
||||
bool GetJoystickEnabled();
|
||||
bool GetJoystickEnabled() const;
|
||||
//@}
|
||||
|
||||
//! Polls the state of joystick axes and buttons
|
||||
|
@ -276,15 +290,15 @@ public:
|
|||
void UpdateMouse();
|
||||
|
||||
//! Returns the current key modifiers
|
||||
int GetKmods();
|
||||
int GetKmods() const;
|
||||
//! Returns whether the given kmod is active
|
||||
bool GetKmodState(int kmod);
|
||||
bool GetKmodState(int kmod) const;
|
||||
|
||||
//! Returns whether the tracked key is pressed
|
||||
bool GetTrackedKeyState(TrackedKey key);
|
||||
bool GetTrackedKeyState(TrackedKey key) const;
|
||||
|
||||
//! Returns whether the mouse button is pressed
|
||||
bool GetMouseButtonState(int index);
|
||||
bool GetMouseButtonState(int index) const;
|
||||
|
||||
//! Resets tracked key states and modifiers
|
||||
void ResetKeyStates();
|
||||
|
@ -292,40 +306,44 @@ public:
|
|||
//! Management of the grab mode for input (keyboard & mouse)
|
||||
//@{
|
||||
void SetGrabInput(bool grab);
|
||||
bool GetGrabInput();
|
||||
bool GetGrabInput() const;
|
||||
//@}
|
||||
|
||||
//! Management of mouse mode
|
||||
//@{
|
||||
void SetMouseMode(MouseMode mode);
|
||||
MouseMode GetMouseMode();
|
||||
MouseMode GetMouseMode() const;
|
||||
//@}
|
||||
|
||||
//! Returns the position of mouse cursor (in interface coords)
|
||||
Math::Point GetMousePos();
|
||||
Math::Point GetMousePos() const;
|
||||
|
||||
//! Moves (warps) the mouse cursor to the specified position (in interface coords)
|
||||
void MoveMouse(Math::Point pos);
|
||||
|
||||
//! Management of debug mode (prints more info in logger)
|
||||
//! Management of debug modes (printing more info in logger)
|
||||
//@{
|
||||
void SetDebugMode(bool mode);
|
||||
bool GetDebugMode();
|
||||
void SetDebugModeActive(DebugMode mode, bool active);
|
||||
bool IsDebugModeActive(DebugMode mode) const;
|
||||
static bool ParseDebugModes(const std::string& str, int& debugModes);
|
||||
//@}
|
||||
|
||||
//! Returns the full path to data directory
|
||||
std::string GetDataDirPath();
|
||||
std::string GetDataDirPath() const;
|
||||
|
||||
//! Returns the full path to a standard dir in data directory
|
||||
std::string GetDataSubdirPath(DataDir stdDir);
|
||||
std::string GetDataSubdirPath(DataDir stdDir) const;
|
||||
|
||||
//! Returns the full path to a file in data directory given standard dir and subpath
|
||||
std::string GetDataFilePath(DataDir stdDir, const std::string &subpath);
|
||||
std::string GetDataFilePath(DataDir stdDir, const std::string &subpath) const;
|
||||
|
||||
//! Returns the full path to a file in texture pack directory
|
||||
std::string GetTexPackFilePath(const std::string& textureName) const;
|
||||
|
||||
//! Management of language
|
||||
//@{
|
||||
Language GetLanguage();
|
||||
char GetLanguageChar();
|
||||
Language GetLanguage() const;
|
||||
char GetLanguageChar() const;
|
||||
void SetLanguage(Language language);
|
||||
static bool ParseLanguage(const std::string& str, Language& language);
|
||||
//@}
|
||||
|
@ -333,16 +351,18 @@ public:
|
|||
//! Management of sleep in main loop (lowers CPU usage)
|
||||
//@{
|
||||
void SetLowCPU(bool low);
|
||||
bool GetLowCPU();
|
||||
bool GetLowCPU() const;
|
||||
//@}
|
||||
|
||||
//! Management of performance counters
|
||||
//@{
|
||||
void StartPerformanceCounter(PerformanceCounter counter);
|
||||
void StopPerformanceCounter(PerformanceCounter counter);
|
||||
float GetPerformanceCounterData(PerformanceCounter counter);
|
||||
float GetPerformanceCounterData(PerformanceCounter counter) const;
|
||||
//@}
|
||||
|
||||
bool GetProtoMode() const;
|
||||
|
||||
protected:
|
||||
//! Creates the window's SDL_Surface
|
||||
bool CreateVideoSurface();
|
||||
|
@ -353,8 +373,8 @@ protected:
|
|||
Event CreateVirtualEvent(const Event& sourceEvent);
|
||||
//! Prepares a simulation update event
|
||||
TEST_VIRTUAL Event CreateUpdateEvent();
|
||||
//! Handles some incoming events
|
||||
bool ProcessEvent(const Event& event);
|
||||
//! Logs debug data for event
|
||||
void LogEvent(const Event& event);
|
||||
//! Renders the image in window
|
||||
void Render();
|
||||
|
||||
|
@ -363,6 +383,9 @@ protected:
|
|||
//! Closes the joystick device
|
||||
void CloseJoystick();
|
||||
|
||||
//! Internal procedure to reset time counters
|
||||
void InternalResumeSimulation();
|
||||
|
||||
//! Resets all performance counters to zero
|
||||
void ResetPerformanceCounters();
|
||||
//! Updates performance counters from gathered timer data
|
||||
|
@ -374,6 +397,8 @@ protected:
|
|||
//! Instance manager
|
||||
// TODO: to be removed
|
||||
CInstanceManager* m_iMan;
|
||||
//! Object manager
|
||||
CObjectManager* m_objMan;
|
||||
//! Global event queue
|
||||
CEventQueue* m_eventQueue;
|
||||
//! Graphics engine
|
||||
|
@ -393,8 +418,8 @@ protected:
|
|||
int m_exitCode;
|
||||
//! Whether application window is active
|
||||
bool m_active;
|
||||
//! Whether debug mode is enabled
|
||||
bool m_debugMode;
|
||||
//! Bit array of active debug modes
|
||||
long m_debugModes;
|
||||
|
||||
//! Message to be displayed as error to the user
|
||||
std::string m_errorMessage;
|
||||
|
@ -458,12 +483,24 @@ protected:
|
|||
//! Path to directory with language files
|
||||
std::string m_langPath;
|
||||
|
||||
const char* m_dataDirs[DIR_MAX];
|
||||
//! Path to directory with user texture pack
|
||||
std::string m_texPackPath;
|
||||
|
||||
//@{
|
||||
//! Scene to run on startup
|
||||
std::string m_runSceneName;
|
||||
int m_runSceneRank;
|
||||
//@}
|
||||
|
||||
const char* m_standardDataDirs[DIR_MAX];
|
||||
|
||||
//! Application language
|
||||
Language m_language;
|
||||
|
||||
//! Low cpu mode
|
||||
bool m_lowCPU;
|
||||
|
||||
//! Show prototype levels
|
||||
bool m_protoMode;
|
||||
};
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
|||
{
|
||||
CLogger logger; // single istance of logger
|
||||
|
||||
InitializeRestext(); // init static translation strings
|
||||
// Initialize static string arrays
|
||||
InitializeRestext();
|
||||
InitializeEventTypeTexts();
|
||||
|
||||
CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
systemUtils->Init();
|
||||
|
@ -122,3 +124,4 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
|||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
@ -188,12 +188,13 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string CSystemUtils::profileFileLocation()
|
||||
std::string CSystemUtils::GetProfileFileLocation()
|
||||
{
|
||||
return std::string("colobot.ini");
|
||||
return std::string("colobot.ini");
|
||||
}
|
||||
|
||||
std::string CSystemUtils::savegameDirectoryLocation()
|
||||
std::string CSystemUtils::GetSavegameDirectoryLocation()
|
||||
{
|
||||
return std::string("savegame");
|
||||
return std::string("savegame");
|
||||
}
|
||||
|
||||
|
|
|
@ -131,10 +131,10 @@ public:
|
|||
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
|
||||
|
||||
//! Returns the profile (colobot.ini) file location
|
||||
virtual std::string profileFileLocation();
|
||||
virtual std::string GetProfileFileLocation();
|
||||
|
||||
//! Returns the savegame directory location
|
||||
virtual std::string savegameDirectoryLocation();
|
||||
virtual std::string GetSavegameDirectoryLocation();
|
||||
};
|
||||
|
||||
//! Global function to get CSystemUtils instance
|
||||
|
@ -142,3 +142,4 @@ inline CSystemUtils* GetSystemUtils()
|
|||
{
|
||||
return CSystemUtils::GetInstancePointer();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,9 +95,9 @@ long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemT
|
|||
(after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll;
|
||||
}
|
||||
|
||||
std::string CSystemUtilsLinux::profileFileLocation()
|
||||
std::string CSystemUtilsLinux::GetProfileFileLocation()
|
||||
{
|
||||
std::string m_profileFile;
|
||||
std::string profileFile;
|
||||
|
||||
// Determine profileFile according to XDG Base Directory Specification
|
||||
char* envXDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
|
||||
|
@ -106,25 +106,25 @@ std::string CSystemUtilsLinux::profileFileLocation()
|
|||
char *envHOME = getenv("HOME");
|
||||
if (envHOME == NULL)
|
||||
{
|
||||
m_profileFile = "colobot.ini";
|
||||
profileFile = "colobot.ini";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profileFile = std::string(envHOME) + "/.config/colobot.ini";
|
||||
profileFile = std::string(envHOME) + "/.config/colobot.ini";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini";
|
||||
profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini";
|
||||
}
|
||||
GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str());
|
||||
GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
|
||||
|
||||
return m_profileFile;
|
||||
return profileFile;
|
||||
}
|
||||
|
||||
std::string CSystemUtilsLinux::savegameDirectoryLocation()
|
||||
std::string CSystemUtilsLinux::GetSavegameDirectoryLocation()
|
||||
{
|
||||
std::string m_savegameDir;
|
||||
std::string savegameDir;
|
||||
|
||||
// Determine savegame dir according to XDG Base Directory Specification
|
||||
char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA");
|
||||
|
@ -133,18 +133,19 @@ std::string CSystemUtilsLinux::savegameDirectoryLocation()
|
|||
char *envHOME = getenv("HOME");
|
||||
if (envHOME == NULL)
|
||||
{
|
||||
m_savegameDir = "/tmp/colobot-savegame";
|
||||
savegameDir = "/tmp/colobot-savegame";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_savegameDir = std::string(envHOME) + "/.local/share/colobot";
|
||||
{
|
||||
savegameDir = std::string(envHOME) + "/.local/share/colobot";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_savegameDir = std::string(envXDG_DATA_HOME) + "/colobot";
|
||||
savegameDir = std::string(envXDG_DATA_HOME) + "/colobot";
|
||||
}
|
||||
GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str());
|
||||
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
|
||||
|
||||
return m_savegameDir;
|
||||
return savegameDir;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,10 @@ public:
|
|||
virtual long long GetTimeStampExactResolution() override;
|
||||
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
|
||||
|
||||
virtual std::string profileFileLocation() override;
|
||||
virtual std::string savegameDirectoryLocation() override;
|
||||
virtual std::string GetProfileFileLocation() override;
|
||||
virtual std::string GetSavegameDirectoryLocation() override;
|
||||
|
||||
private:
|
||||
bool m_zenityAvailable;
|
||||
};
|
||||
|
||||
|
|
|
@ -37,3 +37,4 @@ long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, Sys
|
|||
{
|
||||
return (after->sdlTicks - before->sdlTicks) * 1000000ll;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,3 +46,4 @@ public:
|
|||
virtual long long GetTimeStampExactResolution() override;
|
||||
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -111,38 +111,39 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
|
|||
|
||||
}
|
||||
|
||||
std::string CSystemUtilsWindows::profileFileLocation()
|
||||
std::string CSystemUtilsWindows::GetProfileFileLocation()
|
||||
{
|
||||
std::string m_profileFile;
|
||||
std::string profileFile;
|
||||
|
||||
char* envUSERPROFILE = getenv("USERPROFILE");
|
||||
if (envUSERPROFILE == NULL)
|
||||
{
|
||||
m_profileFile = "colobot.ini";
|
||||
profileFile = "colobot.ini";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
|
||||
profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
|
||||
}
|
||||
GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str());
|
||||
GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
|
||||
|
||||
return m_profileFile;
|
||||
return profileFile;
|
||||
}
|
||||
|
||||
std::string CSystemUtilsWindows::savegameDirectoryLocation()
|
||||
std::string CSystemUtilsWindows::GetSavegameDirectoryLocation()
|
||||
{
|
||||
std::string m_savegameDir;
|
||||
std::string savegameDir;
|
||||
|
||||
char* envUSERPROFILE = getenv("USERPROFILE");
|
||||
if (envUSERPROFILE == NULL)
|
||||
{
|
||||
m_savegameDir = "savegame";
|
||||
savegameDir = "savegame";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
|
||||
savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
|
||||
}
|
||||
GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str());
|
||||
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
|
||||
|
||||
return savegameDir;
|
||||
}
|
||||
|
||||
return m_savegameDir;
|
||||
}
|
|
@ -44,8 +44,8 @@ public:
|
|||
virtual long long GetTimeStampExactResolution() override;
|
||||
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
|
||||
|
||||
virtual std::string profileFileLocation() override;
|
||||
virtual std::string savegameDirectoryLocation() override;
|
||||
virtual std::string GetProfileFileLocation() override;
|
||||
virtual std::string GetSavegameDirectoryLocation() override;
|
||||
|
||||
private:
|
||||
std::string UTF8_Encode(const std::wstring &wstr);
|
||||
|
@ -54,3 +54,4 @@ private:
|
|||
protected:
|
||||
long long m_counterFrequency;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# CMake config header
|
||||
config.h
|
|
@ -2,3 +2,4 @@
|
|||
* \dir src/common
|
||||
* \brief Structs and utils shared throughout the application
|
||||
*/
|
||||
|
||||
|
|
|
@ -23,3 +23,4 @@
|
|||
|
||||
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
|
||||
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
|
||||
|
||||
|
|
|
@ -19,15 +19,541 @@
|
|||
|
||||
#include "common/logger.h"
|
||||
|
||||
static EventType g_uniqueEventType = EVENT_USER;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
static EventType UNIQUE_EVENT_TYPE = EVENT_USER;
|
||||
const char* EVENT_TYPE_TEXT[EVENT_STD_MAX];
|
||||
}
|
||||
|
||||
EventType GetUniqueEventType()
|
||||
{
|
||||
int i = static_cast<int>(g_uniqueEventType+1);
|
||||
g_uniqueEventType = static_cast<EventType>(i);
|
||||
return g_uniqueEventType;
|
||||
int i = static_cast<int>(UNIQUE_EVENT_TYPE+1);
|
||||
UNIQUE_EVENT_TYPE = static_cast<EventType>(i);
|
||||
return UNIQUE_EVENT_TYPE;
|
||||
}
|
||||
|
||||
void InitializeEventTypeTexts()
|
||||
{
|
||||
for (int i = 0; i < EVENT_STD_MAX; ++i)
|
||||
EVENT_TYPE_TEXT[i] = "";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_NULL] = "EVENT_NULL";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_QUIT] = "EVENT_QUIT";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_FRAME] = "EVENT_FRAME";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_DOWN] = "EVENT_MOUSE_BUTTON_DOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_UP] = "EVENT_MOUSE_BUTTON_UP";
|
||||
EVENT_TYPE_TEXT[EVENT_MOUSE_WHEEL] = "EVENT_MOUSE_WHEEL";
|
||||
EVENT_TYPE_TEXT[EVENT_MOUSE_MOVE] = "EVENT_MOUSE_MOVE";
|
||||
EVENT_TYPE_TEXT[EVENT_KEY_DOWN] = "EVENT_KEY_DOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_KEY_UP] = "EVENT_KEY_UP";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_ACTIVE] = "EVENT_ACTIVE";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_JOY_AXIS] = "EVENT_JOY_AXIS";
|
||||
EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_DOWN] = "EVENT_JOY_BUTTON_DOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_UP] = "EVENT_JOY_BUTTON_UP";
|
||||
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_UPDINTERFACE] = "EVENT_UPDINTERFACE";
|
||||
EVENT_TYPE_TEXT[EVENT_WIN] = "EVENT_WIN";
|
||||
EVENT_TYPE_TEXT[EVENT_LOST] = "EVENT_LOST";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_FOCUS] = "EVENT_FOCUS";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON_OK] = "EVENT_BUTTON_OK";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON_CANCEL] = "EVENT_BUTTON_CANCEL";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON_NEXT] = "EVENT_BUTTON_NEXT";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON_PREV] = "EVENT_BUTTON_PREV";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON_QUIT] = "EVENT_BUTTON_QUIT";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON0] = "EVENT_BUTTON0";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON1] = "EVENT_BUTTON1";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON2] = "EVENT_BUTTON2";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON3] = "EVENT_BUTTON3";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON4] = "EVENT_BUTTON4";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON5] = "EVENT_BUTTON5";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON6] = "EVENT_BUTTON6";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON7] = "EVENT_BUTTON7";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON8] = "EVENT_BUTTON8";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON9] = "EVENT_BUTTON9";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON10] = "EVENT_BUTTON10";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON11] = "EVENT_BUTTON11";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON12] = "EVENT_BUTTON12";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON13] = "EVENT_BUTTON13";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON14] = "EVENT_BUTTON14";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON15] = "EVENT_BUTTON15";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON16] = "EVENT_BUTTON16";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON17] = "EVENT_BUTTON17";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON18] = "EVENT_BUTTON18";
|
||||
EVENT_TYPE_TEXT[EVENT_BUTTON19] = "EVENT_BUTTON19";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT0] = "EVENT_EDIT0";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT1] = "EVENT_EDIT1";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT2] = "EVENT_EDIT2";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT3] = "EVENT_EDIT3";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT4] = "EVENT_EDIT4";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT5] = "EVENT_EDIT5";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT6] = "EVENT_EDIT6";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT7] = "EVENT_EDIT7";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT8] = "EVENT_EDIT8";
|
||||
EVENT_TYPE_TEXT[EVENT_EDIT9] = "EVENT_EDIT9";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW0] = "EVENT_WINDOW0";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW1] = "EVENT_WINDOW1";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW2] = "EVENT_WINDOW2";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW3] = "EVENT_WINDOW3";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW4] = "EVENT_WINDOW4";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW5] = "EVENT_WINDOW5";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW6] = "EVENT_WINDOW6";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW7] = "EVENT_WINDOW7";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW8] = "EVENT_WINDOW8";
|
||||
EVENT_TYPE_TEXT[EVENT_WINDOW9] = "EVENT_WINDOW9";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL0] = "EVENT_LABEL0";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL1] = "EVENT_LABEL1";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL2] = "EVENT_LABEL2";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL3] = "EVENT_LABEL3";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL4] = "EVENT_LABEL4";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL5] = "EVENT_LABEL5";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL6] = "EVENT_LABEL6";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL7] = "EVENT_LABEL7";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL8] = "EVENT_LABEL8";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL9] = "EVENT_LABEL9";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL10] = "EVENT_LABEL10";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL11] = "EVENT_LABEL11";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL12] = "EVENT_LABEL12";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL13] = "EVENT_LABEL13";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL14] = "EVENT_LABEL14";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL15] = "EVENT_LABEL15";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL16] = "EVENT_LABEL16";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL17] = "EVENT_LABEL17";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL18] = "EVENT_LABEL18";
|
||||
EVENT_TYPE_TEXT[EVENT_LABEL19] = "EVENT_LABEL19";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_LIST0] = "EVENT_LIST0";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST1] = "EVENT_LIST1";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST2] = "EVENT_LIST2";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST3] = "EVENT_LIST3";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST4] = "EVENT_LIST4";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST5] = "EVENT_LIST5";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST6] = "EVENT_LIST6";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST7] = "EVENT_LIST7";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST8] = "EVENT_LIST8";
|
||||
EVENT_TYPE_TEXT[EVENT_LIST9] = "EVENT_LIST9";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_TOOLTIP] = "EVENT_TOOLTIP";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_OK] = "EVENT_DIALOG_OK";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_CANCEL] = "EVENT_DIALOG_CANCEL";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL] = "EVENT_DIALOG_LABEL";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL1] = "EVENT_DIALOG_LABEL1";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL2] = "EVENT_DIALOG_LABEL2";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL3] = "EVENT_DIALOG_LABEL3";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_LIST] = "EVENT_DIALOG_LIST";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_EDIT] = "EVENT_DIALOG_EDIT";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK1] = "EVENT_DIALOG_CHECK1";
|
||||
EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK2] = "EVENT_DIALOG_CHECK2";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_TRAINER] = "EVENT_INTERFACE_TRAINER";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_DEFI] = "EVENT_INTERFACE_DEFI";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_MISSION] = "EVENT_INTERFACE_MISSION";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_FREE] = "EVENT_INTERFACE_FREE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PROTO] = "EVENT_INTERFACE_PROTO";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NAME] = "EVENT_INTERFACE_NAME";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUP] = "EVENT_INTERFACE_SETUP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_QUIT] = "EVENT_INTERFACE_QUIT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_BACK] = "EVENT_INTERFACE_BACK";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_AGAIN] = "EVENT_INTERFACE_AGAIN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_WRITE] = "EVENT_INTERFACE_WRITE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_READ] = "EVENT_INTERFACE_READ";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_ABORT] = "EVENT_INTERFACE_ABORT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_USER] = "EVENT_INTERFACE_USER";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_TEEN] = "EVENT_INTERFACE_TEEN";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_CHAP] = "EVENT_INTERFACE_CHAP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_LIST] = "EVENT_INTERFACE_LIST";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_RESUME] = "EVENT_INTERFACE_RESUME";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PLAY] = "EVENT_INTERFACE_PLAY";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPd] = "EVENT_INTERFACE_SETUPd";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPg] = "EVENT_INTERFACE_SETUPg";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPp] = "EVENT_INTERFACE_SETUPp";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPc] = "EVENT_INTERFACE_SETUPc";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPs] = "EVENT_INTERFACE_SETUPs";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_DEVICE] = "EVENT_INTERFACE_DEVICE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_RESOL] = "EVENT_INTERFACE_RESOL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_FULL] = "EVENT_INTERFACE_FULL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_APPLY] = "EVENT_INTERFACE_APPLY";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_TOTO] = "EVENT_INTERFACE_TOTO";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SHADOW] = "EVENT_INTERFACE_SHADOW";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_DIRTY] = "EVENT_INTERFACE_DIRTY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_LENS] = "EVENT_INTERFACE_LENS";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SKY] = "EVENT_INTERFACE_SKY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PLANET] = "EVENT_INTERFACE_PLANET";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_LIGHT] = "EVENT_INTERFACE_LIGHT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PARTI] = "EVENT_INTERFACE_PARTI";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_CLIP] = "EVENT_INTERFACE_CLIP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_DETAIL] = "EVENT_INTERFACE_DETAIL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE] = "EVENT_INTERFACE_TEXTURE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_RAIN] = "EVENT_INTERFACE_RAIN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINT] = "EVENT_INTERFACE_GLINT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_TOOLTIP] = "EVENT_INTERFACE_TOOLTIP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_MOVIES] = "EVENT_INTERFACE_MOVIES";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NICERST] = "EVENT_INTERFACE_NICERST";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SCROLL] = "EVENT_INTERFACE_SCROLL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT] = "EVENT_INTERFACE_EFFECT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_MOUSE] = "EVENT_INTERFACE_MOUSE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GROUND] = "EVENT_INTERFACE_GROUND";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GADGET] = "EVENT_INTERFACE_GADGET";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_FOG] = "EVENT_INTERFACE_FOG";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_HIMSELF] = "EVENT_INTERFACE_HIMSELF";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITMODE]= "EVENT_INTERFACE_EDITMODE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITVALUE]= "EVENT_INTERFACE_EDITVALUE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE4] = "EVENT_INTERFACE_SOLUCE4";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO1] = "EVENT_INTERFACE_KINFO1";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO2] = "EVENT_INTERFACE_KINFO2";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KGROUP] = "EVENT_INTERFACE_KGROUP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KSCROLL] = "EVENT_INTERFACE_KSCROLL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KDEF] = "EVENT_INTERFACE_KDEF";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KLEFT] = "EVENT_INTERFACE_KLEFT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KRIGHT] = "EVENT_INTERFACE_KRIGHT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KUP] = "EVENT_INTERFACE_KUP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KDOWN] = "EVENT_INTERFACE_KDOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KGUP] = "EVENT_INTERFACE_KGUP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KGDOWN] = "EVENT_INTERFACE_KGDOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KCAMERA] = "EVENT_INTERFACE_KCAMERA";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KDESEL] = "EVENT_INTERFACE_KDESEL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KACTION] = "EVENT_INTERFACE_KACTION";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEAR] = "EVENT_INTERFACE_KNEAR";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KAWAY] = "EVENT_INTERFACE_KAWAY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEXT] = "EVENT_INTERFACE_KNEXT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KHUMAN] = "EVENT_INTERFACE_KHUMAN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KQUIT] = "EVENT_INTERFACE_KQUIT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KHELP] = "EVENT_INTERFACE_KHELP";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KPROG] = "EVENT_INTERFACE_KPROG";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KCBOT] = "EVENT_INTERFACE_KCBOT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KVISIT] = "EVENT_INTERFACE_KVISIT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED10]= "EVENT_INTERFACE_KSPEED10";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED15]= "EVENT_INTERFACE_KSPEED15";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED20]= "EVENT_INTERFACE_KSPEED20";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED30]= "EVENT_INTERFACE_KSPEED30";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLSOUND]= "EVENT_INTERFACE_VOLSOUND";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLMUSIC]= "EVENT_INTERFACE_VOLMUSIC";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SOUND3D] = "EVENT_INTERFACE_SOUND3D";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_MIN] = "EVENT_INTERFACE_MIN";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NORM] = "EVENT_INTERFACE_NORM";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_MAX] = "EVENT_INTERFACE_MAX";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SILENT] = "EVENT_INTERFACE_SILENT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NOISY] = "EVENT_INTERFACE_NOISY";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_JOYSTICK]= "EVENT_INTERFACE_JOYSTICK";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE] = "EVENT_INTERFACE_SOLUCE";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTl] = "EVENT_INTERFACE_GLINTl";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTr] = "EVENT_INTERFACE_GLINTr";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTu] = "EVENT_INTERFACE_GLINTu";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTb] = "EVENT_INTERFACE_GLINTb";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NEDIT] = "EVENT_INTERFACE_NEDIT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NLIST] = "EVENT_INTERFACE_NLIST";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NOK] = "EVENT_INTERFACE_NOK";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NCANCEL] = "EVENT_INTERFACE_NCANCEL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NDELETE] = "EVENT_INTERFACE_NDELETE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_NLABEL] = "EVENT_INTERFACE_NLABEL";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IOWRITE] = "EVENT_INTERFACE_IOWRITE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IOREAD] = "EVENT_INTERFACE_IOREAD";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLIST] = "EVENT_INTERFACE_IOLIST";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IONAME] = "EVENT_INTERFACE_IONAME";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLABEL] = "EVENT_INTERFACE_IOLABEL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IOIMAGE] = "EVENT_INTERFACE_IOIMAGE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_IODELETE]= "EVENT_INTERFACE_IODELETE";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PERSO] = "EVENT_INTERFACE_PERSO";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_POK] = "EVENT_INTERFACE_POK";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCANCEL] = "EVENT_INTERFACE_PCANCEL";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PDEF] = "EVENT_INTERFACE_PDEF";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PHEAD] = "EVENT_INTERFACE_PHEAD";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PBODY] = "EVENT_INTERFACE_PBODY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PLROT] = "EVENT_INTERFACE_PLROT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PRROT] = "EVENT_INTERFACE_PRROT";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0a] = "EVENT_INTERFACE_PC0a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1a] = "EVENT_INTERFACE_PC1a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2a] = "EVENT_INTERFACE_PC2a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3a] = "EVENT_INTERFACE_PC3a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4a] = "EVENT_INTERFACE_PC4a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5a] = "EVENT_INTERFACE_PC5a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6a] = "EVENT_INTERFACE_PC6a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7a] = "EVENT_INTERFACE_PC7a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8a] = "EVENT_INTERFACE_PC8a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9a] = "EVENT_INTERFACE_PC9a";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRa] = "EVENT_INTERFACE_PCRa";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGa] = "EVENT_INTERFACE_PCGa";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBa] = "EVENT_INTERFACE_PCBa";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0b] = "EVENT_INTERFACE_PC0b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1b] = "EVENT_INTERFACE_PC1b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2b] = "EVENT_INTERFACE_PC2b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3b] = "EVENT_INTERFACE_PC3b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4b] = "EVENT_INTERFACE_PC4b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5b] = "EVENT_INTERFACE_PC5b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6b] = "EVENT_INTERFACE_PC6b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7b] = "EVENT_INTERFACE_PC7b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8b] = "EVENT_INTERFACE_PC8b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9b] = "EVENT_INTERFACE_PC9b";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRb] = "EVENT_INTERFACE_PCRb";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGb] = "EVENT_INTERFACE_PCGb";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBb] = "EVENT_INTERFACE_PCBb";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE1] = "EVENT_INTERFACE_PFACE1";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE2] = "EVENT_INTERFACE_PFACE2";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE3] = "EVENT_INTERFACE_PFACE3";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE4] = "EVENT_INTERFACE_PFACE4";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS0] = "EVENT_INTERFACE_PGLASS0";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS1] = "EVENT_INTERFACE_PGLASS1";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS2] = "EVENT_INTERFACE_PGLASS2";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS3] = "EVENT_INTERFACE_PGLASS3";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS4] = "EVENT_INTERFACE_PGLASS4";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS5] = "EVENT_INTERFACE_PGLASS5";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS6] = "EVENT_INTERFACE_PGLASS6";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS7] = "EVENT_INTERFACE_PGLASS7";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS8] = "EVENT_INTERFACE_PGLASS8";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS9] = "EVENT_INTERFACE_PGLASS9";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_DT_GROUP0] = "EVENT_DT_GROUP0";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_GROUP1] = "EVENT_DT_GROUP1";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_GROUP2] = "EVENT_DT_GROUP2";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_GROUP3] = "EVENT_DT_GROUP3";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_GROUP4] = "EVENT_DT_GROUP4";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_LABEL0] = "EVENT_DT_LABEL0";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_LABEL1] = "EVENT_DT_LABEL1";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_LABEL2] = "EVENT_DT_LABEL2";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_LABEL3] = "EVENT_DT_LABEL3";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_LABEL4] = "EVENT_DT_LABEL4";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_VISIT0] = "EVENT_DT_VISIT0";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_VISIT1] = "EVENT_DT_VISIT1";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_VISIT2] = "EVENT_DT_VISIT2";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_VISIT3] = "EVENT_DT_VISIT3";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_VISIT4] = "EVENT_DT_VISIT4";
|
||||
EVENT_TYPE_TEXT[EVENT_DT_END] = "EVENT_DT_END";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_CMD] = "EVENT_CMD";
|
||||
EVENT_TYPE_TEXT[EVENT_SPEED] = "EVENT_SPEED";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_PREV] = "EVENT_HYPER_PREV";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_NEXT] = "EVENT_HYPER_NEXT";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_HOME] = "EVENT_HYPER_HOME";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_COPY] = "EVENT_HYPER_COPY";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_SIZE1] = "EVENT_HYPER_SIZE1";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_SIZE2] = "EVENT_HYPER_SIZE2";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_SIZE3] = "EVENT_HYPER_SIZE3";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_SIZE4] = "EVENT_HYPER_SIZE4";
|
||||
EVENT_TYPE_TEXT[EVENT_HYPER_SIZE5] = "EVENT_HYPER_SIZE5";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_HUSTON] = "EVENT_SATCOM_HUSTON";
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_SAT] = "EVENT_SATCOM_SAT";
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_LOADING] = "EVENT_SATCOM_LOADING";
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_OBJECT] = "EVENT_SATCOM_OBJECT";
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_PROG] = "EVENT_SATCOM_PROG";
|
||||
EVENT_TYPE_TEXT[EVENT_SATCOM_SOLUCE] = "EVENT_SATCOM_SOLUCE";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_DESELECT] = "EVENT_OBJECT_DESELECT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_LEFT] = "EVENT_OBJECT_LEFT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RIGHT] = "EVENT_OBJECT_RIGHT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_UP] = "EVENT_OBJECT_UP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_DOWN] = "EVENT_OBJECT_DOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GASUP] = "EVENT_OBJECT_GASUP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GASDOWN] = "EVENT_OBJECT_GASDOWN";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_HTAKE] = "EVENT_OBJECT_HTAKE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MTAKE] = "EVENT_OBJECT_MTAKE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MFRONT] = "EVENT_OBJECT_MFRONT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MBACK] = "EVENT_OBJECT_MBACK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MPOWER] = "EVENT_OBJECT_MPOWER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BHELP] = "EVENT_OBJECT_BHELP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BTAKEOFF] = "EVENT_OBJECT_BTAKEOFF";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROY] = "EVENT_OBJECT_BDESTROY";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BDERRICK] = "EVENT_OBJECT_BDERRICK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BSTATION] = "EVENT_OBJECT_BSTATION";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BFACTORY] = "EVENT_OBJECT_BFACTORY";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BCONVERT] = "EVENT_OBJECT_BCONVERT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BTOWER] = "EVENT_OBJECT_BTOWER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BREPAIR] = "EVENT_OBJECT_BREPAIR";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BRESEARCH] = "EVENT_OBJECT_BRESEARCH";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BRADAR] = "EVENT_OBJECT_BRADAR";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BENERGY] = "EVENT_OBJECT_BENERGY";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BLABO] = "EVENT_OBJECT_BLABO";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BNUCLEAR] = "EVENT_OBJECT_BNUCLEAR";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BPARA] = "EVENT_OBJECT_BPARA";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BINFO] = "EVENT_OBJECT_BINFO";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROYER] = "EVENT_OBJECT_BDESTROYER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GFLAT] = "EVENT_OBJECT_GFLAT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCREATE] = "EVENT_OBJECT_FCREATE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FDELETE] = "EVENT_OBJECT_FDELETE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORb] = "EVENT_OBJECT_FCOLORb";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORr] = "EVENT_OBJECT_FCOLORr";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORg] = "EVENT_OBJECT_FCOLORg";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORy] = "EVENT_OBJECT_FCOLORy";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORv] = "EVENT_OBJECT_FCOLORv";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwa] = "EVENT_OBJECT_FACTORYwa";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYta] = "EVENT_OBJECT_FACTORYta";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfa] = "EVENT_OBJECT_FACTORYfa";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYia] = "EVENT_OBJECT_FACTORYia";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwc] = "EVENT_OBJECT_FACTORYwc";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYtc] = "EVENT_OBJECT_FACTORYtc";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfc] = "EVENT_OBJECT_FACTORYfc";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYic] = "EVENT_OBJECT_FACTORYic";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwi] = "EVENT_OBJECT_FACTORYwi";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYti] = "EVENT_OBJECT_FACTORYti";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfi] = "EVENT_OBJECT_FACTORYfi";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYii] = "EVENT_OBJECT_FACTORYii";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYws] = "EVENT_OBJECT_FACTORYws";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYts] = "EVENT_OBJECT_FACTORYts";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfs] = "EVENT_OBJECT_FACTORYfs";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYis] = "EVENT_OBJECT_FACTORYis";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrt] = "EVENT_OBJECT_FACTORYrt";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrc] = "EVENT_OBJECT_FACTORYrc";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrr] = "EVENT_OBJECT_FACTORYrr";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrs] = "EVENT_OBJECT_FACTORYrs";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYsa] = "EVENT_OBJECT_FACTORYsa";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SEARCH] = "EVENT_OBJECT_SEARCH";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_TERRAFORM] = "EVENT_OBJECT_TERRAFORM";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FIRE] = "EVENT_OBJECT_FIRE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_FIREANT] = "EVENT_OBJECT_FIREANT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SPIDEREXPLO]= "EVENT_OBJECT_SPIDEREXPLO";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RECOVER] = "EVENT_OBJECT_RECOVER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_BEGSHIELD] = "EVENT_OBJECT_BEGSHIELD";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_ENDSHIELD] = "EVENT_OBJECT_ENDSHIELD";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RTANK] = "EVENT_OBJECT_RTANK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RFLY] = "EVENT_OBJECT_RFLY";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RTHUMP] = "EVENT_OBJECT_RTHUMP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RCANON] = "EVENT_OBJECT_RCANON";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RTOWER] = "EVENT_OBJECT_RTOWER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RPHAZER] = "EVENT_OBJECT_RPHAZER";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RSHIELD] = "EVENT_OBJECT_RSHIELD";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RATOMIC] = "EVENT_OBJECT_RATOMIC";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RiPAW] = "EVENT_OBJECT_RiPAW";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RiGUN] = "EVENT_OBJECT_RiGUN";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_RESET] = "EVENT_OBJECT_RESET";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_DIMSHIELD] = "EVENT_OBJECT_DIMSHIELD";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_TARGET] = "EVENT_OBJECT_TARGET";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PROGLIST] = "EVENT_OBJECT_PROGLIST";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PROGRUN] = "EVENT_OBJECT_PROGRUN";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PROGEDIT] = "EVENT_OBJECT_PROGEDIT";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTART] = "EVENT_OBJECT_PROGSTART";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTOP] = "EVENT_OBJECT_PROGSTOP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_INFOOK] = "EVENT_OBJECT_INFOOK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_DELETE] = "EVENT_OBJECT_DELETE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GENERGY] = "EVENT_OBJECT_GENERGY";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GSHIELD] = "EVENT_OBJECT_GSHIELD";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GRANGE] = "EVENT_OBJECT_GRANGE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_COMPASS] = "EVENT_OBJECT_COMPASS";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MAP] = "EVENT_OBJECT_MAP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MAPZOOM] = "EVENT_OBJECT_MAPZOOM";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GPROGRESS] = "EVENT_OBJECT_GPROGRESS";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GRADAR] = "EVENT_OBJECT_GRADAR";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_GINFO] = "EVENT_OBJECT_GINFO";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_TYPE] = "EVENT_OBJECT_TYPE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CROSSHAIR] = "EVENT_OBJECT_CROSSHAIR";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERul] = "EVENT_OBJECT_CORNERul";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERur] = "EVENT_OBJECT_CORNERur";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdl] = "EVENT_OBJECT_CORNERdl";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdr] = "EVENT_OBJECT_CORNERdr";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MAPi] = "EVENT_OBJECT_MAPi";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MAPg] = "EVENT_OBJECT_MAPg";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERA] = "EVENT_OBJECT_CAMERA";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_HELP] = "EVENT_OBJECT_HELP";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SOLUCE] = "EVENT_OBJECT_SOLUCE";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAleft] = "EVENT_OBJECT_CAMERAleft";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAright]= "EVENT_OBJECT_CAMERAright";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAnear] = "EVENT_OBJECT_CAMERAnear";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAaway] = "EVENT_OBJECT_CAMERAaway";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT00] = "EVENT_OBJECT_SHORTCUT00";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT01] = "EVENT_OBJECT_SHORTCUT01";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT02] = "EVENT_OBJECT_SHORTCUT02";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT03] = "EVENT_OBJECT_SHORTCUT03";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT04] = "EVENT_OBJECT_SHORTCUT04";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT05] = "EVENT_OBJECT_SHORTCUT05";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT06] = "EVENT_OBJECT_SHORTCUT06";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT07] = "EVENT_OBJECT_SHORTCUT07";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT08] = "EVENT_OBJECT_SHORTCUT08";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT09] = "EVENT_OBJECT_SHORTCUT09";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT10] = "EVENT_OBJECT_SHORTCUT10";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT11] = "EVENT_OBJECT_SHORTCUT11";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT12] = "EVENT_OBJECT_SHORTCUT12";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT13] = "EVENT_OBJECT_SHORTCUT13";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT14] = "EVENT_OBJECT_SHORTCUT14";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT15] = "EVENT_OBJECT_SHORTCUT15";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT16] = "EVENT_OBJECT_SHORTCUT16";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT17] = "EVENT_OBJECT_SHORTCUT17";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT18] = "EVENT_OBJECT_SHORTCUT18";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT19] = "EVENT_OBJECT_SHORTCUT19";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_MOVIELOCK] = "EVENT_OBJECT_MOVIELOCK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_EDITLOCK] = "EVENT_OBJECT_EDITLOCK";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_LIMIT] = "EVENT_OBJECT_LIMIT";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN0] = "EVENT_OBJECT_PEN0";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN1] = "EVENT_OBJECT_PEN1";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN2] = "EVENT_OBJECT_PEN2";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN3] = "EVENT_OBJECT_PEN3";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN4] = "EVENT_OBJECT_PEN4";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN5] = "EVENT_OBJECT_PEN5";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN6] = "EVENT_OBJECT_PEN6";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN7] = "EVENT_OBJECT_PEN7";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_PEN8] = "EVENT_OBJECT_PEN8";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_REC] = "EVENT_OBJECT_REC";
|
||||
EVENT_TYPE_TEXT[EVENT_OBJECT_STOP] = "EVENT_OBJECT_STOP";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_OK] = "EVENT_STUDIO_OK";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_CANCEL] = "EVENT_STUDIO_CANCEL";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_EDIT] = "EVENT_STUDIO_EDIT";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_LIST] = "EVENT_STUDIO_LIST";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_NEW] = "EVENT_STUDIO_NEW";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_OPEN] = "EVENT_STUDIO_OPEN";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_SAVE] = "EVENT_STUDIO_SAVE";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_UNDO] = "EVENT_STUDIO_UNDO";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_CUT] = "EVENT_STUDIO_CUT";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_COPY] = "EVENT_STUDIO_COPY";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_PASTE] = "EVENT_STUDIO_PASTE";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_SIZE] = "EVENT_STUDIO_SIZE";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_TOOL] = "EVENT_STUDIO_TOOL";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_HELP] = "EVENT_STUDIO_HELP";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_COMPILE] = "EVENT_STUDIO_COMPILE";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_RUN] = "EVENT_STUDIO_RUN";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_REALTIME] = "EVENT_STUDIO_REALTIME";
|
||||
EVENT_TYPE_TEXT[EVENT_STUDIO_STEP] = "EVENT_STUDIO_STEP";
|
||||
}
|
||||
|
||||
std::string ParseEventType(EventType eventType)
|
||||
{
|
||||
auto Other = [&](const char* name)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << name << "(" << static_cast<int>(eventType) << ")";
|
||||
return str.str();
|
||||
};
|
||||
|
||||
if (eventType < EVENT_STD_MAX)
|
||||
{
|
||||
const char* stdEvent = EVENT_TYPE_TEXT[eventType];
|
||||
if (stdEvent[0] == 0)
|
||||
return Other("STD_UNDEFINED");
|
||||
|
||||
return stdEvent;
|
||||
}
|
||||
|
||||
if (eventType >= EVENT_USER)
|
||||
return Other("USER_EVENT");
|
||||
|
||||
return Other("UNDEFINED");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,8 +40,10 @@ enum EventType
|
|||
//! Invalid event / no event
|
||||
EVENT_NULL = 0,
|
||||
|
||||
//! Event sent on user or system quit request
|
||||
EVENT_QUIT = 1,
|
||||
// System events (originating in CApplication)
|
||||
|
||||
//! Event sent on system quit request
|
||||
EVENT_SYS_QUIT = 1,
|
||||
|
||||
//! Frame update event
|
||||
EVENT_FRAME = 2,
|
||||
|
@ -69,10 +71,15 @@ enum EventType
|
|||
//! Event sent after releasing a joystick button
|
||||
EVENT_JOY_BUTTON_UP = 14,
|
||||
|
||||
//!< Maximum value of system events
|
||||
EVENT_SYS_MAX,
|
||||
|
||||
|
||||
/* Events sent/received in game and user interface */
|
||||
|
||||
EVENT_UPDINTERFACE = 20,
|
||||
//! Event sent on user quit request
|
||||
EVENT_QUIT = 20,
|
||||
EVENT_UPDINTERFACE = 21,
|
||||
EVENT_WIN = 30,
|
||||
EVENT_LOST = 31,
|
||||
|
||||
|
@ -396,6 +403,7 @@ enum EventType
|
|||
EVENT_OBJECT_MPOWER = 1024,
|
||||
EVENT_OBJECT_BHELP = 1040,
|
||||
EVENT_OBJECT_BTAKEOFF = 1041,
|
||||
EVENT_OBJECT_BDESTROY = 1042,
|
||||
EVENT_OBJECT_BDERRICK = 1050,
|
||||
EVENT_OBJECT_BSTATION = 1051,
|
||||
EVENT_OBJECT_BFACTORY = 1052,
|
||||
|
@ -547,7 +555,8 @@ enum EventType
|
|||
EVENT_STUDIO_REALTIME = 2052,
|
||||
EVENT_STUDIO_STEP = 2053,
|
||||
|
||||
EVENT_STD_MAX, //! < maximum value of standard events
|
||||
//! Maximum value of standard events
|
||||
EVENT_STD_MAX,
|
||||
|
||||
EVENT_USER = 10000,
|
||||
EVENT_FORCE_LONG = 0x7fffffff
|
||||
|
@ -668,8 +677,8 @@ struct ActiveEventData
|
|||
* \struct Event
|
||||
* \brief Event sent by system, interface or game
|
||||
*
|
||||
* Event is described by its type (EventType) and the union
|
||||
* \a data contains additional data about the event.
|
||||
* Event is described by its type (EventType) and anonymous union that
|
||||
* contains additional data about the event.
|
||||
* Different members of the union are filled with different event types.
|
||||
* With some events, nothing is filled (it's zeroed out).
|
||||
* The union contains roughly the same information as SDL_Event struct
|
||||
|
@ -680,9 +689,6 @@ struct Event
|
|||
//! Type of event
|
||||
EventType type;
|
||||
|
||||
//! If true, the event was produced by system in CApplication; else, it has come from game engine
|
||||
bool systemEvent;
|
||||
|
||||
//! Relative time since last EVENT_FRAME
|
||||
//! Scope: only EVENT_FRAME events
|
||||
// TODO: gradually replace the usage of this with new CApplication's time functions
|
||||
|
@ -729,22 +735,25 @@ struct Event
|
|||
ActiveEventData active;
|
||||
};
|
||||
|
||||
Event(EventType type = EVENT_NULL)
|
||||
{
|
||||
this->type = type;
|
||||
|
||||
systemEvent = false;
|
||||
rTime = 0.0f;
|
||||
mouseButtonsState = 0;
|
||||
trackedKeysState = 0;
|
||||
customParam = 0;
|
||||
}
|
||||
explicit Event(EventType _type = EVENT_NULL)
|
||||
: type(_type)
|
||||
, rTime(0.0f)
|
||||
, kmodState(0)
|
||||
, trackedKeysState(0)
|
||||
, mouseButtonsState(0)
|
||||
, customParam(0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
//! Returns an unique event type (above the standard IDs)
|
||||
EventType GetUniqueEventType();
|
||||
|
||||
//! Initializes static array with event type strings
|
||||
void InitializeEventTypeTexts();
|
||||
|
||||
//! Parses event type to string
|
||||
std::string ParseEventType(EventType eventType);
|
||||
|
||||
/**
|
||||
* \class CEventQueue
|
||||
|
@ -778,3 +787,4 @@ protected:
|
|||
int m_tail;
|
||||
int m_total;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ enum Error
|
|||
ERR_BUILD_BASE = 129, //! < too close to the rocket
|
||||
ERR_BUILD_NARROW = 130, //! < buildings too close
|
||||
ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
|
||||
ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission
|
||||
ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object
|
||||
ERR_SEARCH_FLY = 140, //! < not possible in flight
|
||||
ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
|
||||
ERR_SEARCH_MOTOR = 142, //! < impossible in movement
|
||||
|
@ -104,6 +106,8 @@ enum Error
|
|||
ERR_INFO_NULL = 390, //! < no information terminal
|
||||
ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
|
||||
ERR_BAT_VIRUS = 401, //! < building infected by a virus
|
||||
ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy
|
||||
ERR_WRONG_OBJ = 420, //! < inappropriate vehicle
|
||||
ERR_VEH_POWER = 500, //! < no battery
|
||||
ERR_VEH_ENERGY = 501, //! < more energy
|
||||
ERR_FLAG_FLY = 510, //! < impossible in flight
|
||||
|
@ -293,3 +297,4 @@ extern int g_build; // constructible buildings
|
|||
extern int g_researchDone; // research done
|
||||
extern long g_researchEnable; // research available
|
||||
extern float g_unit; // conversion factor
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "common/image.h"
|
||||
|
||||
#include "math/func.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -108,7 +110,8 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
@ -199,6 +202,33 @@ void CImage::Fill(Gfx::IntColor color)
|
|||
SDL_FillRect(m_data->surface, nullptr, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Image must be valid.
|
||||
*
|
||||
* The dimensions are increased to nearest even power of two values.
|
||||
* If image is already in power-of-two format, nothing is done.
|
||||
*/
|
||||
void CImage::PadToNearestPowerOfTwo()
|
||||
{
|
||||
assert(m_data != nullptr);
|
||||
|
||||
if (Math::IsPowerOfTwo(m_data->surface->w) && Math::IsPowerOfTwo(m_data->surface->h))
|
||||
return;
|
||||
|
||||
int w = Math::NextPowerOfTwo(m_data->surface->w);
|
||||
int h = Math::NextPowerOfTwo(m_data->surface->h);
|
||||
|
||||
m_data->surface->flags &= (~SDL_SRCALPHA);
|
||||
SDL_Surface* resizedSurface = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00,
|
||||
0x000000ff, 0xff000000);
|
||||
assert(resizedSurface != NULL);
|
||||
SDL_BlitSurface(m_data->surface, NULL, resizedSurface, NULL);
|
||||
|
||||
SDL_FreeSurface(m_data->surface);
|
||||
|
||||
m_data->surface = resizedSurface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image must be valid and pixel coords in valid range.
|
||||
*
|
||||
|
@ -367,3 +397,4 @@ bool CImage::SavePNG(const std::string& fileName)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
//! Returns the precise color at given pixel
|
||||
Gfx::IntColor GetPixelInt(Math::IntPoint pixel);
|
||||
|
||||
//! Pads the image to nearest power of 2 dimensions
|
||||
void PadToNearestPowerOfTwo();
|
||||
|
||||
//! Loads an image from the specified file
|
||||
bool Load(const std::string &fileName);
|
||||
|
||||
|
@ -109,3 +112,4 @@ private:
|
|||
//! Image data
|
||||
ImageData* m_data;
|
||||
};
|
||||
|
||||
|
|
|
@ -111,3 +111,4 @@ void CInstanceManager::Compress(ManagedClassType classType)
|
|||
}
|
||||
m_table[classType].usedCount = j;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,4 +93,3 @@ protected:
|
|||
ManagedClassInstances m_table[CLASS_MAX];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -146,3 +146,4 @@ std::string ReadBinaryString(std::istream &istr)
|
|||
}
|
||||
|
||||
}; // namespace IOUtils
|
||||
|
||||
|
|
|
@ -61,3 +61,4 @@ enum VirtualKmod
|
|||
|
||||
//! Special value for invalid key bindings
|
||||
const unsigned int KEY_INVALID = SDLK_LAST + 1000;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
|
|||
|
||||
CLogger::CLogger()
|
||||
{
|
||||
mFile = NULL;
|
||||
mLogLevel = LOG_INFO;
|
||||
m_file = NULL;
|
||||
m_logLevel = LOG_INFO;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,31 +38,31 @@ CLogger::~CLogger()
|
|||
|
||||
void CLogger::Log(LogLevel type, const char* str, va_list args)
|
||||
{
|
||||
if (type < mLogLevel)
|
||||
if (type < m_logLevel)
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case LOG_TRACE:
|
||||
fprintf(IsOpened() ? mFile : stderr, "[TRACE]: ");
|
||||
fprintf(IsOpened() ? m_file : stderr, "[TRACE]: ");
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: ");
|
||||
fprintf(IsOpened() ? m_file : stderr, "[DEBUG]: ");
|
||||
break;
|
||||
case LOG_WARN:
|
||||
fprintf(IsOpened() ? mFile : stderr, "[WARN]: ");
|
||||
fprintf(IsOpened() ? m_file : stderr, "[WARN]: ");
|
||||
break;
|
||||
case LOG_INFO:
|
||||
fprintf(IsOpened() ? mFile : stderr, "[INFO]: ");
|
||||
fprintf(IsOpened() ? m_file : stderr, "[INFO]: ");
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
fprintf(IsOpened() ? mFile : stderr, "[ERROR]: ");
|
||||
fprintf(IsOpened() ? m_file : stderr, "[ERROR]: ");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vfprintf(IsOpened() ? mFile : stderr, str, args);
|
||||
vfprintf(IsOpened() ? m_file : stderr, str, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,36 +122,36 @@ void CLogger::Message(const char* str, ...)
|
|||
|
||||
void CLogger::SetOutputFile(std::string filename)
|
||||
{
|
||||
mFilename = filename;
|
||||
m_filename = filename;
|
||||
Open();
|
||||
}
|
||||
|
||||
|
||||
void CLogger::Open()
|
||||
{
|
||||
mFile = fopen(mFilename.c_str(), "w");
|
||||
m_file = fopen(m_filename.c_str(), "w");
|
||||
|
||||
if (mFile == NULL)
|
||||
fprintf(stderr, "Could not create file %s\n", mFilename.c_str());
|
||||
if (m_file == NULL)
|
||||
fprintf(stderr, "Could not create file %s\n", m_filename.c_str());
|
||||
}
|
||||
|
||||
|
||||
void CLogger::Close()
|
||||
{
|
||||
if (IsOpened())
|
||||
fclose(mFile);
|
||||
fclose(m_file);
|
||||
}
|
||||
|
||||
|
||||
bool CLogger::IsOpened()
|
||||
{
|
||||
return mFile != NULL;
|
||||
return m_file != NULL;
|
||||
}
|
||||
|
||||
|
||||
void CLogger::SetLogLevel(LogLevel type)
|
||||
{
|
||||
mLogLevel = type;
|
||||
m_logLevel = type;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -113,9 +113,9 @@ public:
|
|||
static bool ParseLogLevel(const std::string& str, LogLevel& logLevel);
|
||||
|
||||
private:
|
||||
std::string mFilename;
|
||||
FILE *mFile;
|
||||
LogLevel mLogLevel;
|
||||
std::string m_filename;
|
||||
FILE *m_file;
|
||||
LogLevel m_logLevel;
|
||||
|
||||
void Open();
|
||||
void Close();
|
||||
|
@ -125,6 +125,8 @@ private:
|
|||
|
||||
|
||||
//! Global function to get Logger instance
|
||||
inline CLogger* GetLogger() {
|
||||
inline CLogger* GetLogger()
|
||||
{
|
||||
return CLogger::GetInstancePointer();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,3 +31,4 @@ extern void TimeToAscii(time_t time, char *buffer);
|
|||
|
||||
extern bool CopyFileListToTemp(char* filename, int* list, int total);
|
||||
extern void AddExt(char* filename, const char* ext);
|
||||
|
||||
|
|
|
@ -39,17 +39,7 @@ CProfile::CProfile() :
|
|||
|
||||
CProfile::~CProfile()
|
||||
{
|
||||
if (m_profileNeedSave)
|
||||
{
|
||||
try
|
||||
{
|
||||
bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on storing profile: %s\n", e.what());
|
||||
}
|
||||
}
|
||||
SaveCurrentDirectory();
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,17 +47,40 @@ bool CProfile::InitCurrentDirectory()
|
|||
{
|
||||
try
|
||||
{
|
||||
bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
|
||||
#if DEV_BUILD
|
||||
bp::ini_parser::read_ini("colobot.ini", m_propertyTree);
|
||||
#else
|
||||
bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
|
||||
#endif
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CProfile::SaveCurrentDirectory()
|
||||
{
|
||||
if (m_profileNeedSave)
|
||||
{
|
||||
try
|
||||
{
|
||||
#if DEV_BUILD
|
||||
bp::ini_parser::write_ini("colobot.ini", m_propertyTree);
|
||||
#else
|
||||
bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
|
||||
#endif
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Error("Error on storing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value)
|
||||
{
|
||||
|
@ -78,7 +91,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std::
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -93,7 +106,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std::
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -109,7 +122,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -124,7 +137,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -140,7 +153,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -155,7 +168,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -179,7 +192,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section,
|
|||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Info("Error on parsing profile: %s\n", e.what());
|
||||
GetLogger()->Error("Error on parsing profile: %s\n", e.what());
|
||||
}
|
||||
|
||||
return ret_list;
|
||||
|
@ -196,34 +209,39 @@ std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir)
|
|||
{
|
||||
std::string path = dir;
|
||||
boost::replace_all(path, "\\", "/");
|
||||
if (dir.find("/") == std::string::npos) {
|
||||
if (dir.find("/") == std::string::npos)
|
||||
{
|
||||
path = default_dir + "/" + dir;
|
||||
}
|
||||
|
||||
if (m_userDirectory.length() > 0) {
|
||||
|
||||
if (m_userDirectory.length() > 0)
|
||||
{
|
||||
boost::replace_all(path, "%user%", m_userDirectory);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::replace_all(path, "%user%", default_dir);
|
||||
}
|
||||
|
||||
|
||||
return fs::path(path).make_preferred().string();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CProfile::CopyFileToTemp(std::string filename)
|
||||
{
|
||||
std::string src, dst;
|
||||
std::string tmp_user_dir = m_userDirectory;
|
||||
|
||||
|
||||
src = GetUserBasedPath(filename, "textures");
|
||||
SetUserDir("temp");
|
||||
dst = GetUserBasedPath(filename, "textures");
|
||||
SetUserDir(tmp_user_dir);
|
||||
|
||||
|
||||
fs::create_directory(fs::path(dst).parent_path().make_preferred().string());
|
||||
fs::copy_file(src, dst, fs::copy_option::overwrite_if_exists);
|
||||
if (fs::exists(dst)) {
|
||||
return true;
|
||||
if (fs::exists(dst))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -41,96 +41,103 @@ namespace fs = boost::filesystem;
|
|||
*/
|
||||
class CProfile : public CSingleton<CProfile>
|
||||
{
|
||||
public:
|
||||
CProfile();
|
||||
~CProfile();
|
||||
public:
|
||||
CProfile();
|
||||
virtual ~CProfile();
|
||||
|
||||
/** Loads colobot.ini from current directory
|
||||
* \return return true on success
|
||||
*/
|
||||
bool InitCurrentDirectory();
|
||||
/** Loads colobot.ini from current directory
|
||||
* \return return true on success
|
||||
*/
|
||||
bool InitCurrentDirectory();
|
||||
|
||||
/** Sets string value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileString(std::string section, std::string key, std::string value);
|
||||
/** Saves colobot.ini to current directory
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SaveCurrentDirectory();
|
||||
|
||||
/** Gets string value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param buffer
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileString(std::string section, std::string key, std::string& buffer);
|
||||
/** Sets string value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileString(std::string section, std::string key, std::string value);
|
||||
|
||||
/** Sets int value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileInt(std::string section, std::string key, int value);
|
||||
/** Gets string value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param buffer
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileString(std::string section, std::string key, std::string& buffer);
|
||||
|
||||
/** Gets int value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileInt(std::string section, std::string key, int &value);
|
||||
/** Sets int value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileInt(std::string section, std::string key, int value);
|
||||
|
||||
/** Sets float value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileFloat(std::string section, std::string key, float value);
|
||||
/** Gets int value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileInt(std::string section, std::string key, int &value);
|
||||
|
||||
/** Gets float value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileFloat(std::string section, std::string key, float &value);
|
||||
/** Sets float value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool SetLocalProfileFloat(std::string section, std::string key, float value);
|
||||
|
||||
/** Gets all values in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \return vector of values
|
||||
*/
|
||||
std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
|
||||
|
||||
/** Sets current user directory
|
||||
* \param dir
|
||||
*/
|
||||
void SetUserDir(std::string dir);
|
||||
|
||||
/** Returns path based on current user. Replaces %user% in path with current user dir or
|
||||
* uses default_dir param if no user dir is specified
|
||||
* \param dir
|
||||
* \param default_dir
|
||||
* \return path
|
||||
*/
|
||||
std::string GetUserBasedPath(std::string dir, std::string default_dir);
|
||||
|
||||
/** opy a file into the temporary folder.
|
||||
* \param filename
|
||||
* \return true on success
|
||||
*/
|
||||
bool CopyFileToTemp(std::string filename);
|
||||
/** Gets float value in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \param value
|
||||
* \return return true on success
|
||||
*/
|
||||
bool GetLocalProfileFloat(std::string section, std::string key, float &value);
|
||||
|
||||
private:
|
||||
boost::property_tree::ptree m_propertyTree;
|
||||
bool m_profileNeedSave;
|
||||
std::string m_userDirectory;
|
||||
/** Gets all values in section under specified key
|
||||
* \param section
|
||||
* \param key
|
||||
* \return vector of values
|
||||
*/
|
||||
std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
|
||||
|
||||
/** Sets current user directory
|
||||
* \param dir
|
||||
*/
|
||||
void SetUserDir(std::string dir);
|
||||
|
||||
/** Returns path based on current user. Replaces %user% in path with current user dir or
|
||||
* uses default_dir param if no user dir is specified
|
||||
* \param dir
|
||||
* \param default_dir
|
||||
* \return path
|
||||
*/
|
||||
std::string GetUserBasedPath(std::string dir, std::string default_dir);
|
||||
|
||||
/** opy a file into the temporary folder.
|
||||
* \param filename
|
||||
* \return true on success
|
||||
*/
|
||||
bool CopyFileToTemp(std::string filename);
|
||||
|
||||
private:
|
||||
boost::property_tree::ptree m_propertyTree;
|
||||
bool m_profileNeedSave;
|
||||
std::string m_userDirectory;
|
||||
};
|
||||
|
||||
//! Global function to get profile instance
|
||||
inline CProfile & GetProfile() {
|
||||
inline CProfile & GetProfile()
|
||||
{
|
||||
return *CProfile::GetInstancePointer();
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,7 @@ void InitializeRestext()
|
|||
stringsEvent[EVENT_OBJECT_MPOWER] = "..power cell";
|
||||
stringsEvent[EVENT_OBJECT_BHELP] = "Instructions for the mission (\\key help;)";
|
||||
stringsEvent[EVENT_OBJECT_BTAKEOFF] = "Take off to finish the mission";
|
||||
stringsEvent[EVENT_OBJECT_BDESTROY] = "Destroy";
|
||||
stringsEvent[EVENT_OBJECT_BDERRICK] = "Build a derrick";
|
||||
stringsEvent[EVENT_OBJECT_BSTATION] = "Build a power station";
|
||||
stringsEvent[EVENT_OBJECT_BFACTORY] = "Build a bot factory";
|
||||
|
@ -539,6 +540,7 @@ void InitializeRestext()
|
|||
|
||||
|
||||
|
||||
stringsErr[ERR_GENERIC] = "Internal error - tell the developers";
|
||||
stringsErr[ERR_CMD] = "Unknown command";
|
||||
stringsErr[ERR_MANIP_VEH] = "Inappropriate bot";
|
||||
stringsErr[ERR_MANIP_FLY] = "Impossible when flying";
|
||||
|
@ -563,6 +565,8 @@ void InitializeRestext()
|
|||
stringsErr[ERR_BUILD_NARROW] = "Too close to a building";
|
||||
stringsErr[ERR_BUILD_MOTOR] = "Impossible when moving";
|
||||
stringsErr[ERR_SEARCH_FLY] = "Impossible when flying";
|
||||
stringsErr[ERR_BUILD_DISABLED] = "Can not produce this object in this mission";
|
||||
stringsErr[ERR_BUILD_RESEARCH] = "Can not produce not researched object";
|
||||
stringsErr[ERR_SEARCH_VEH] = "Inappropriate bot";
|
||||
stringsErr[ERR_SEARCH_MOTOR] = "Impossible when moving";
|
||||
stringsErr[ERR_TERRA_VEH] = "Inappropriate bot";
|
||||
|
@ -620,6 +624,8 @@ void InitializeRestext()
|
|||
stringsErr[ERR_FLAG_CREATE] = "Too many flags of this color (maximum 5)";
|
||||
stringsErr[ERR_FLAG_PROXY] = "Too close to an existing flag";
|
||||
stringsErr[ERR_FLAG_DELETE] = "No flag nearby";
|
||||
stringsErr[ERR_DESTROY_NOTFOUND]= "Not found anything to destroy";
|
||||
stringsErr[ERR_WRONG_OBJ] = "Inappropriate object";
|
||||
stringsErr[ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)";
|
||||
stringsErr[ERR_DELETEMOBILE] = "Bot destroyed";
|
||||
stringsErr[ERR_DELETEBUILDING] = "Building destroyed";
|
||||
|
@ -729,9 +735,9 @@ void InitializeRestext()
|
|||
|
||||
static char g_gamerName[100];
|
||||
|
||||
void SetGlobalGamerName(char *name)
|
||||
void SetGlobalGamerName(std::string name)
|
||||
{
|
||||
strcpy(g_gamerName, name);
|
||||
strcpy(g_gamerName, name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -842,10 +848,8 @@ static const char* GetResourceBase(ResType type, int num)
|
|||
|
||||
case RES_EVENT:
|
||||
if (num >= EVENT_STD_MAX)
|
||||
{
|
||||
GetLogger()->Trace("GetResource event num out of range: %d\n", num); // TODO: fix later
|
||||
return "";
|
||||
}
|
||||
return ""; // can be safely ignored (user events)
|
||||
|
||||
str = stringsEvent[num];
|
||||
break;
|
||||
|
||||
|
@ -914,3 +918,4 @@ bool GetResource(ResType type, int num, char* text)
|
|||
PutKeyName(text, tmpl);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "common/global.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/**
|
||||
* \enum ResType
|
||||
|
@ -153,6 +155,7 @@ enum ResTextType
|
|||
|
||||
void InitializeRestext();
|
||||
|
||||
void SetGlobalGamerName(char *name);
|
||||
void SetGlobalGamerName(std::string name);
|
||||
bool SearchKey(const char *cmd, InputSlot& slot);
|
||||
bool GetResource(ResType type, int num, char* text);
|
||||
|
||||
|
|
|
@ -74,3 +74,4 @@ private:
|
|||
CSingleton& operator=(const CSingleton<T> &);
|
||||
CSingleton(const CSingleton<T> &);
|
||||
};
|
||||
|
||||
|
|
|
@ -142,3 +142,4 @@ size_t StrUtils::Utf8StringLength(const std::string &str)
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,3 +78,4 @@ int Utf8CharSizeAt(const std::string &str, unsigned int pos);
|
|||
size_t Utf8StringLength(const std::string &str);
|
||||
|
||||
}; // namespace StrUtil
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
lang/
|
|
@ -1,97 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Install Desktop Entry file
|
||||
set(COLOBOT_DESKTOP_FILE colobot.desktop)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
|
||||
)
|
||||
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
|
||||
)
|
||||
|
||||
# Install Icon
|
||||
set(COLOBOT_ICON_FILE colobot.svg)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
|
||||
)
|
||||
|
||||
# Render SVG icon in various sizes
|
||||
find_program(RSVG_CONVERT rsvg-convert)
|
||||
if(RSVG_CONVERT)
|
||||
foreach(PNGSIZE "48" "32" "16")
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE})
|
||||
add_custom_target(resize_icon_${PNGSIZE} ALL
|
||||
COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
> ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Create manpage from pod-formatted file
|
||||
find_program(POD2MAN pod2man)
|
||||
if(POD2MAN AND (NOT MSYS))
|
||||
set(COLOBOT_MANPAGE_SECTION 6)
|
||||
|
||||
macro(podman)
|
||||
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
|
||||
if(PM_LOCALE)
|
||||
# This copes with the fact that english has no "/LANG" in the paths and filenames.
|
||||
set(SLASHLOCALE /${PM_LOCALE})
|
||||
endif()
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
||||
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
|
||||
--center="Colobot" --stderr --utf8
|
||||
--release="${COLOBOT_VERSION_FULL}"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
|
||||
)
|
||||
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
|
||||
|
||||
add_dependencies(man man${PM_LOCALE})
|
||||
endmacro()
|
||||
|
||||
# Create the english manpage
|
||||
podman(PODFILE colobot.pod)
|
||||
|
||||
endif()
|
||||
|
||||
# Translate translatable material
|
||||
find_program(PO4A po4a)
|
||||
|
||||
if(PO4A)
|
||||
add_custom_target(desktop_po4a
|
||||
COMMAND ${PO4A} po4a.cfg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(desktopfile desktop_po4a)
|
||||
|
||||
if(POD2MAN)
|
||||
add_custom_target(man_po4a
|
||||
COMMAND ${PO4A} po4a.cfg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(man man_po4a)
|
||||
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
|
||||
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
|
||||
foreach(LOCALE ${LINGUAS})
|
||||
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue