Compare commits

...

1278 Commits

Author SHA1 Message Date
immibis b98edec8f8 Fix some save file corruption (type 0 objects) caused by children of deleted objects not getting properly deleted. 2023-11-20 11:52:37 +01:00
immibis d22b32477e Career: Save the rest of the level as well as just the spaceship. Also put all career save files in __career__ folder. 2023-11-18 19:45:52 +01:00
immibis 884129a676 1000 seems very low 2023-11-18 19:45:06 +01:00
immibis 0fa486b9f0 Add a career mode. The contents of the spaceship are saved on liftoff and restored when loading a level. At the beginning, all levels are unlocked. 2023-11-18 19:06:52 +01:00
immibis 4251873f49 Very similar thing with DrawFront flag 2023-11-18 14:53:58 +01:00
immibis 74ab7afb23 Compute object team on demand - partially. But there's more to team colour, and it was already broken before, so there's no way to see if this did anything. 2023-11-18 14:11:52 +01:00
immibis ab3c22dce3 Compute camera ghost mode on demand - simplifies code as each object doesn't propagate ghost mode to its render objects. 2023-11-18 14:01:02 +01:00
immibis 72ca4f2d7c Each graphics object retains a reference to its associated game object. This will be useful soon. 2023-11-18 13:40:25 +01:00
immibis 3a8f75bd02 string_view is not a drop-in replacement for char[]
Fixes crash on startup - when logging FULL_NAME with %s - on Linux.
2023-10-11 06:04:18 +02:00
immibis 32fed5af73 Fix build - static library used in shared library must have position-independent code 2023-10-11 05:16:06 +02:00
Emxx52 f07b7a1b60
Merge pull request #1612 from colobot/dev-fix-links
Update doc links in README
2023-08-28 23:59:33 +02:00
Fiftytwo 0a95289f9f Update doc links in README 2023-08-28 23:31:44 +02:00
Ceeee 7d75b9cc14
Update German translation (#1607) 2023-08-24 23:32:11 +02:00
tomangelo 909a2b2d2e
Update checkout and upload-artifact actions to node16 (#1610)
* Updated checkout actions

* Updated upload-artifact actions

* Remove now unnecessary gcc-9 step
2023-08-24 23:25:32 +02:00
Emxx52 7d22b607cc
Merge pull request #1609 from colobot/1608-strutilsremovecomments-breaks-some-levels
Fix RemoveComments()
2023-08-24 20:33:02 +02:00
Tomasz Kapuściński 2f80292176 Fix RemoveComments() 2023-08-24 18:45:16 +02:00
Emxx52 53b3062bee
Merge pull request #1606 from colobot/1605-improve-level-loading-time
Improve level loading time
2023-08-23 20:19:17 +02:00
Tomasz Kapuściński 8e128ff08c Added StrUtils::RemoveComments() and used it instead of std::regex in parsing level commands 2023-08-23 16:56:15 +02:00
Emxx52 3c4b9f6d01
Merge pull request #1604 from colobot/dev-graphics-overhaul
Graphics overhaul
2023-08-23 02:06:58 +02:00
Tomasz Kapuściński 9d5f88f07c Merge branch 'dev' into dev-graphics-overhaul 2023-08-22 23:51:12 +02:00
Tomasz Kapuściński b9c8d36d8b Fixed links 2023-08-22 23:29:08 +02:00
Tomasz Kapuściński ff340fda92 Moved docimg to docs/images 2023-08-22 22:52:55 +02:00
Tomasz Kapuściński c0d568241b Moved some documentation files to docs directory 2023-08-22 22:42:40 +02:00
Tomasz Kapuściński d879fa5fc9 Cleanup in unit tests 2023-08-22 22:19:46 +02:00
Tomasz Kapuściński 510fe6804a Extracted CBot tools 2023-08-22 22:01:24 +02:00
Tomasz Kapuściński 2b84da8a77 Removed model converter 2023-08-22 21:50:18 +02:00
Tomasz Kapuściński 670cedd967 Renamed directory tools to scripts 2023-08-22 21:45:11 +02:00
Tomasz Kapuściński 5a52c66b1f Renamed target colobot_ut to Colobot-UnitTests 2023-08-22 21:39:55 +02:00
Tomasz Kapuściński 434bd0bd3a Renamed src to colobot-base and colobotbase target to Colobot-Base 2023-08-22 21:19:03 +02:00
Emxx52 5f854da5fc
Merge pull request #1602 from colobot/dev-upgrade-physfs
Replace deprecated PHYSFS functions with their modern counterparts
2023-08-22 21:01:10 +02:00
tomangelo2 86c2b2f0dc Replace deprecated PHYSFS functions with their modern counterparts 2023-08-17 23:38:02 +02:00
Tomasz Kapuściński 7fe75e20ad Fixed wrong text selection color 2023-08-15 20:32:33 +02:00
Tomasz Kapuściński 261eaa78e4 A fix for Windows stupidity 2023-08-15 19:22:10 +02:00
Tomasz Kapuściński 4d11040dba Split string encoding functionality to Windows and generic implementations 2023-08-15 18:57:34 +02:00
Tomasz Kapuściński 97ea5cc895 Added missing include 2023-08-15 14:34:51 +02:00
Tomasz Kapuściński fe36b0fe29 Build CBot as static library instead 2023-08-15 14:11:05 +02:00
Tomasz Kapuściński 8fab817118 Ensure position-independent code generation 2023-08-15 13:48:02 +02:00
Tomasz Kapuściński 8601066761 Fix for compilation error 2023-08-15 13:41:39 +02:00
Tomasz Kapuściński 9586474fa8 Removed remaining dependency on boost 2023-08-15 12:47:27 +02:00
Tomasz Kapuściński 5b79a4eb38 Extracted StrUtils to a separate target and replaced remaining boost code 2023-08-15 12:25:14 +02:00
Tomasz Kapuściński 1034c2e45c Rewritten config to use JSON instead of INI 2023-08-15 12:02:51 +02:00
Tomasz Kapuściński fde2b901bd Rewritten loading of font config file 2023-08-15 11:16:51 +02:00
Tomasz Kapuściński 3e06584956 Removed unused boost includes 2023-08-15 02:55:33 +02:00
Tomasz Kapuściński 0ab9ae4b6e Replaced boost::adaptor::reverse with reverse iterators
Changes based on f0f6f61cab
2023-08-15 02:51:28 +02:00
Tomasz Kapuściński b296ee4d47 Added StrUtils::Split() and replaced boost::split() 2023-08-15 02:41:40 +02:00
Tomasz Kapuściński dccacd6352 Rewritten UnicodeStringToUtf8() and increased buffer size 2023-08-14 22:26:00 +02:00
Tomasz Kapuściński b3c6e667f5 Rewritten UTF-8 implementation using standard library 2023-08-14 21:46:05 +02:00
Tomasz Kapuściński a48f13fb35 Fix for missing setlocale() 2023-08-14 00:11:15 +02:00
Tomasz Kapuściński 7db69f5d53 Changed include 2023-08-13 23:46:00 +02:00
Tomasz Kapuściński ae5e5b3874 Added missing includes 2023-08-13 23:31:12 +02:00
Tomasz Kapuściński b5b3f81840 Added ToLower() and ToUpper() 2023-08-13 23:22:22 +02:00
Tomasz Kapuściński fd81641cf7 Updated CI pipeline build for MacOS 2023-08-13 22:36:13 +02:00
Tomasz Kapuściński 840ded7e61 Renamed colobot to colobot-app 2023-08-13 21:20:37 +02:00
Tomasz Kapuściński 4c7e7280dd Added missing build preset 2023-08-13 20:44:51 +02:00
Tomasz Kapuściński af1abfe41e Updated CI pipeline build for Linux 2023-08-13 20:22:52 +02:00
Tomasz Kapuściński 8e950e5145 Updated CI pipeline build for Windows 2023-08-13 19:51:57 +02:00
Tomasz Kapuściński e807e7c984 Added missing include 2023-08-13 18:48:30 +02:00
Tomasz Kapuściński d9d401e636 Removed extra semicolon 2023-08-13 17:56:16 +02:00
Tomasz Kapuściński 9a14d0c837 Added missing include 2023-08-13 17:40:40 +02:00
Tomasz Kapuściński ee9f9d875d Replaced remaining MakeUnique 2023-08-13 17:39:12 +02:00
Tomasz Kapuściński b12e5ad7cd Replaced boost::replace_all with StrUtils::Replace
Also fixed a bug in it and added tests for it.
Changes based on f0f6f61cab
2023-08-09 21:43:15 +02:00
Tomasz Kapuściński ecb789d059 Replaced boost::trim functions with new Trim functions
Changes based on f0f6f61cab
2023-08-09 20:11:08 +02:00
Tomasz Kapuściński 32fb105bca Replaced boost::algorithm::join with standard algorithms
Changes based on f0f6f61cab
2023-08-09 19:52:44 +02:00
Tomasz Kapuściński 7d3e3c91e8 Replaced boost::tokenizer with std::istringstream
Changes based on f0f6f61cab
2023-08-09 19:40:54 +02:00
Tomasz Kapuściński 1b69589302 Replaced boost::lexical_cast with other implementations
Changes based on f0f6f61cab
2023-08-09 19:32:59 +02:00
Tomasz Kapuściński f7a33bbeb0 Replaced boost::optional and boost::regex with STL implementations
Changes based on f0f6f61cab
2023-08-09 17:58:48 +02:00
Tomasz Kapuściński 0ef77132a0 Replaced boost::filesystem with std::filesystem
Changes based on f0f6f61cab
2023-08-09 17:04:09 +02:00
Tomasz Kapuściński 550193e570 Added Version::DEVELOPMENT_BUILD to check for development build 2023-08-09 16:40:18 +02:00
Tomasz Kapuściński beb29333d5 Replaced boost::bimap with std::map
Code extracted from f0f6f61cab
2023-08-09 16:25:18 +02:00
Tomasz Kapuściński f9714c35f7 Replaced version macrodefinitions with constexpr variables 2023-08-09 15:59:12 +02:00
Tomasz Kapuściński 26598c4247 Rewritten project version specification 2023-08-09 15:27:23 +02:00
Tomasz Kapuściński 1ee0790785 Extracted Colobot executable target to a separate directory 2023-08-09 14:42:24 +02:00
Tomasz Kapuściński 6f05280ccb Extracted CBot library to a separate directory 2023-08-09 13:47:55 +02:00
Tomasz Kapuściński 63b6bcf38d Improved shadow quality
* Default shadow texture is 2048
* Worse shadows use single region
* Always use object shadowing
2023-08-09 12:41:01 +02:00
Tomasz Kapuściński 83b9ded0dc Merge branch 'dev' into dev-graphics-overhaul 2023-08-08 01:01:57 +02:00
Tomasz Kapuściński 84ac0d3ba8 Post-release 0.2.1-alpha 2023-08-08 00:43:51 +02:00
Tomasz Kapuściński acc3c5ae5e Release 0.2.1-alpha: Bump version 2023-08-07 22:47:21 +02:00
tomangelo ec0e735a3f
Merge pull request #1600 from colobot/dev-update-license-headers
Updated license headers
2023-08-06 23:51:44 +02:00
Tomasz Kapuściński a16771425a Updated license headers 2023-08-06 23:15:48 +02:00
Tomasz Kapuściński 4fcd989e72
Merge pull request #1599 from colobot/dev-fix-appimage
Fix AppImage generation
2023-07-22 22:20:15 +02:00
tomangelo2 882672c0b5 Another fix for Appimage generator 2023-07-22 21:31:49 +02:00
tomangelo2 b152bd5dea Fix Appimage generation script 2023-07-22 21:23:13 +02:00
Emxx52 59600ae5c7
Merge pull request #1598 from colobot/dev-readme
Update README files
2023-07-22 11:03:48 +02:00
Fiftytwo 11f5073a3f Replace outdated links in README-dev.md 2023-07-21 23:14:09 +02:00
Fiftytwo cfa9a00024 Replace outdated links in CONTRIBUTING.md 2023-07-21 22:47:40 +02:00
Fiftytwo 9e1248e459 Rewrite README.md 2023-07-21 22:09:33 +02:00
Marcin Puc 9ccc514a67
Add reference to the Void Linux package (#1539) 2023-07-21 22:01:26 +02:00
Tomasz Kapuściński 63ad09b615 Post-merge fixes 2023-07-04 20:35:52 +02:00
Your Name 1376d8b16d Fix planets getting distorted when changing window aspect ratio. 2023-07-04 20:35:52 +02:00
Tomasz Kapuściński a04dcd8014 Fix windows build failure (#1595)
* Added version override for libiconv

* Updated vcpkg baseline, forced PhysFS version 3.0.2

* Updated vcpkg git commit
2023-07-04 20:35:52 +02:00
tomangelo2 9c8a8f4cf4 Better fix for #1587 2023-07-04 20:35:52 +02:00
tomangelo2 dfac4209ef Add slot for Wasps (fix for #1587) 2023-07-04 20:35:52 +02:00
Emxx52 793ef3d0a4 Update Russian translation (#1557)
* Update Russian translation (#1470)

* Update Russian translation

Co-authored-by: X64E <X64E@users.noreply.github.com>
Co-authored-by: Anton-V-K <Anton-V-K@users.noreply.github.com>

* Update data submodule

---------

Co-authored-by: zvladru <30793959+zvladru@users.noreply.github.com>
Co-authored-by: X64E <X64E@users.noreply.github.com>
Co-authored-by: Anton-V-K <Anton-V-K@users.noreply.github.com>
2023-07-04 20:35:52 +02:00
lolbot-iichan 0d57ac43bb UI: Fix scribbler's green button color 2023-07-04 20:35:52 +02:00
Tomasz Kapuściński 3baf2bbb10 Fixed wasp not having a valid cargo slot 2023-07-04 20:35:52 +02:00
Fiftytwo 7c95855d4f Update data submodule 2023-07-04 20:35:52 +02:00
Fiftytwo dd2fbd2675 Add unlocking Phazer research in plus and free 2023-07-04 20:35:52 +02:00
Fiftytwo 8eaebb8c84 Fix missing done research icons on level load 2023-07-04 20:35:52 +02:00
Tomasz Kapuściński 172e1fbff0
Merge pull request #1593 from immibis/fix-squashed-planets
Fix squashed planets when window isn't 4:3
2023-07-03 20:45:13 +02:00
Tomasz Kapuściński 461f1e2240
Fix windows build failure (#1595)
* Added version override for libiconv

* Updated vcpkg baseline, forced PhysFS version 3.0.2

* Updated vcpkg git commit
2023-06-28 23:52:01 +02:00
Emxx52 7c40c10b7a
Merge pull request #1590 from colobot/dev-fix-1587
Change the slot for AlienWasp
2023-06-28 23:50:25 +02:00
Your Name 017a1571f7 Fix planets getting distorted when changing window aspect ratio. 2023-06-28 19:15:51 +02:00
tomangelo2 f672e89201 Better fix for #1587 2023-06-22 23:32:02 +02:00
tomangelo2 9417b916da Add slot for Wasps (fix for #1587) 2023-06-19 00:31:15 +02:00
Emxx52 4f0854068c
Update Russian translation (#1557)
* Update Russian translation (#1470)

* Update Russian translation

Co-authored-by: X64E <X64E@users.noreply.github.com>
Co-authored-by: Anton-V-K <Anton-V-K@users.noreply.github.com>

* Update data submodule

---------

Co-authored-by: zvladru <30793959+zvladru@users.noreply.github.com>
Co-authored-by: X64E <X64E@users.noreply.github.com>
Co-authored-by: Anton-V-K <Anton-V-K@users.noreply.github.com>
2023-05-27 00:47:45 +02:00
Emxx52 3171dc4a89
Merge pull request #1582 from lolbot-iichan/dev-scribbler-ui-fix
UI: Fix scribbler's green button color
2023-05-26 21:35:26 +02:00
Emxx52 10b89e36f9
Merge pull request #1581 from colobot/1580-wasp-grabbing-behavior-broken
Fixed wasp not having a valid cargo slot
2023-05-26 21:12:56 +02:00
Tomasz Kapuściński 080c46daa1 Fixed inverted coordinates 2023-05-15 23:00:50 +02:00
lolbot-iichan b3d19a9e8d
UI: Fix scribbler's green button color 2023-05-15 19:20:56 +03:00
Tomasz Kapuściński 1bb918ce23 Rewritten vertex attribute processing 2023-05-09 02:23:56 +02:00
Tomasz Kapuściński 160a4a4f75 Fixed wasp not having a valid cargo slot 2023-05-07 20:43:43 +02:00
Emxx52 71e3e78644
Merge pull request #1579 from colobot/dev-plus-research
Add unlocking Phazer research after completing missions chapter 9 and fix missing research icons
2023-05-07 16:56:18 +02:00
Fiftytwo 6e7dee74cf Update data submodule 2023-05-07 16:00:02 +02:00
Fiftytwo 8f11fc0126 Add unlocking Phazer research in plus and free 2023-05-07 15:33:17 +02:00
Fiftytwo 5f9b14f43d Fix missing done research icons on level load 2023-05-07 08:42:21 +02:00
Tomasz Kapuściński b66ea8bcee Fixed a couple of warnings 2023-04-15 02:45:33 +02:00
Tomasz Kapuściński 37b403c46d Replaced sprintf() with snprintf() 2023-04-15 02:05:12 +02:00
Tomasz Kapuściński 2e7bf2a7a6 Fixed invalid parameter 2023-04-15 01:06:58 +02:00
Tomasz Kapuściński 4b1b20ec5f Checkout json submodule in Mac build 2023-04-15 00:29:07 +02:00
Tomasz Kapuściński d24a6b37a4 Added glm to installed dependencies 2023-04-15 00:16:56 +02:00
Tomasz Kapuściński 4531dc432e Merge branch 'dev' into dev-graphics-overhaul 2023-04-14 23:41:28 +02:00
Tomasz Kapuściński 06bf44da38
Merge pull request #1575 from colobot/1571-optimize-windows-builds-with-vcpkg
Optimize Windows builds with vcpkg
2023-04-14 18:58:20 +02:00
Tomasz Kapuściński 9dd0159585 Added useless comment for testing 2023-04-10 23:22:23 +02:00
Tomasz Kapuściński 158901ff02 Fixed cached path 2023-04-10 22:36:52 +02:00
Tomasz Kapuściński 9a01408eda Added CMakeUserPresets.json to .gitignore 2023-04-10 21:37:55 +02:00
Tomasz Kapuściński 7c0dbd914f Cache vcpkg dependencies 2023-04-10 20:55:39 +02:00
Tomasz Kapuściński b990ee81ff
Merge pull request #1570 from colobot/1569-remove-ubuntu-1804-actions
Removed Ubuntu 18.04 actions
2023-04-08 21:29:41 +02:00
Tomasz Kapuściński bfd9dae533 Removed Ubuntu 18.04 actions 2023-04-08 20:43:26 +02:00
Tomasz Kapuściński cbfcbae7ab
Merge pull request #1560 from lolbot-iichan/dev-fix-multi-team-ant-legs
ENGINE: Fix operator < for COldModelManager::FileInfo
2023-04-08 19:46:20 +02:00
Tomasz Kapuściński 2e95aeac9b
Merge pull request #1501 from colobot/dev-fix-macos-compilation
Fix compilation under MacOS
2023-04-08 19:11:43 +02:00
Tomasz Kapuściński efbd296fc3 Merge branch 'dev' into dev-fix-macos-compilation 2023-04-08 17:55:03 +02:00
Tomasz Kapuściński 9c5d9d8f17
Merge pull request #1568 from colobot/dev-vcpkg-fixes
vcpkg fixes
2023-04-08 17:49:04 +02:00
Tomasz Kapuściński 0b978f7dbc Use newer version of vcpkg to fix broken link 2023-04-03 00:51:27 +02:00
Tomasz Kapuściński 4634461c1d Added vcpkg manifest file 2023-04-03 00:01:30 +02:00
Tomasz Kapuściński 1c9c0929da
Merge pull request #1559 from suve/add-missing-cstdint-includes
Add missing <cstdint> includes
2023-03-11 11:53:05 +01:00
Tomasz Kapuściński 24622e6a75
Merge pull request #1562 from olokos/dev
Fix For MSVC2022 and Background Pause blur
2023-03-11 11:39:59 +01:00
olokos f60c62f05d Graphics - Engine - Fix pause blur for new SDL 2023-02-06 17:53:56 +01:00
olokos ec9607784c Remove redundant " from CMakeLists.txt 2023-02-06 17:22:05 +01:00
Tomasz Kapuściński 5efd8342ec Updated SDL2 and SDL2_image library names 2023-02-06 17:07:02 +01:00
lolbot-iichan 0618174b2b
ENGINE: Fix operator < for COldModelManager::FileInfo
There was a rare case when Old Model Manager's model base object list was not working correctly.

Testcase:
CreateObject pos=10;0 dir=1.5 type=LeggedTrainer selectable=1 team=1
CreateObject pos=-10;0 dir=0.25 type=LeggedTrainer selectable=1 team=2

Expected result (after fix): models are displayed correctly
Actual result (before fix): some legs are missing, instead of them giant surfaces are floating high above the model

The reason was is failing to find the element that was just created and added with `m_models.find(FileInfo(fileName, mirrored, team))`
This happened for objects that had mirrored body parts (at least Ants, Wasps and all Legged units were affected) in case they were assigned to several teams.
Everyone were missing some legs since the `modelManager->AddModelReference("ant6.mod", true, rank, m_object->GetTeam())`
Wasps were also usually missing some wings.
2023-02-05 16:34:55 +03:00
suve d47e265863 Add missing <cstdint> includes
Some parts of the code used the fixed-size type uint32_t,
which is defined in stdint.h / cstdint - without including said
header file. With GCC13, the inter-header dependencies seem
to have changed and the file is no longer included transitively,
requiring an explicit include.
2023-01-19 10:34:55 +01:00
Tomasz Kapuściński 436c316a4a Updated SDL2 and SDL2_image library names 2022-11-26 20:04:44 +01:00
Tomasz Kapuściński 1d8e06c7ba Revert "Fix for SDL on Windows"
This reverts commit 21b6572b5b.
2022-11-26 20:00:44 +01:00
Tomasz Kapuściński 21b6572b5b Fix for SDL on Windows 2022-11-26 17:42:34 +01:00
Tomasz Kapuściński 3b3cdb9961 Fix for config.h? 2022-11-26 16:15:53 +01:00
Tomasz Kapuściński bedd24801c Better fix? 2022-11-26 15:49:39 +01:00
Tomasz Kapuściński 983a9a6e03 Another fix for SDL 2022-11-26 15:32:56 +01:00
Tomasz Kapuściński 2f50470591 Fix for linking to SDL 2022-11-26 14:52:39 +01:00
Tomasz Kapuściński 5feffc70df Updated vcpkg version 2022-11-26 12:31:54 +01:00
Tomasz Kapuściński e3ba33a508 Rewritten CModelMesh to use separate vertex attributes 2022-11-12 18:52:21 +01:00
Emxx52 b7cb26822b
Update build.yml 2022-11-06 04:12:02 +01:00
tomangelo2 0e53336d61 Merge branch 'dev' into dev-fix-macos-compilation 2022-11-05 19:27:52 +01:00
tomangelo 0df78e7fa6
Merge pull request #1529 from colobot/dev-fix-space
undefined
2022-09-15 02:13:19 +02:00
tomangelo2 789c8b2292 Fix compilation with gcc 2022-09-15 01:14:29 +02:00
tomangelo c0669a591b
Update INSTALL-MacOSX.md 2022-09-15 00:12:54 +02:00
tomangelo 708d3cfd46
Enable building tests
Making .dmg package needs `data` directory, while `make install` does weird stuff with path, for now I'll skip that.
2022-09-14 23:58:42 +02:00
tomangelo 6cc58b872f
Let's try to get tests instead
Making .dmg package needs `data` directory, while `make install` does weird stuff with path, for now I'll skip that.
2022-09-14 23:25:16 +02:00
tomangelo 4c767953ea
Fix path 2022-09-13 21:58:35 +02:00
tomangelo 4ec0083cd8
Try to move binary to separate directory 2022-09-13 21:48:43 +02:00
tomangelo 87ad81f891
Don't try to make package for now 2022-09-13 21:21:49 +02:00
tomangelo afbf687255
Try to fix packaging 2022-09-13 21:03:14 +02:00
tomangelo2 0693aa5e1e Fix OpenAL library path 2022-09-13 20:45:07 +02:00
tomangelo2 2a91d6bf35 Temporarily remove tests 2022-09-13 20:14:47 +02:00
tomangelo2 b09977a503 Merge branch 'dev-fix-macos-compilation' of https://github.com/colobot/colobot into dev-fix-macos-compilation 2022-09-13 20:01:50 +02:00
tomangelo2 438e4bba62 First attempt to run MacOS build on Github Actions 2022-09-13 19:58:11 +02:00
Krzysztof Rewak a74adb5f59
Missing PL translation (#1512)
* missing PL translation

* update po.pl
2022-08-24 20:25:25 +02:00
Tomasz Kapuściński 8632c7404d Refactored NaN implementation
strfind() now returns -1 instead of NaN when substring can't be found
added isnan() as an alternative way of checking if a value is NaN
2022-08-15 00:09:24 +02:00
Tomasz Kapuściński 2ea94244e9 Fixed const-correctness of getters 2022-08-14 23:47:47 +02:00
Tomasz Kapuściński 3c98af04b5 Fixed passing bool to message() 2022-08-13 17:18:14 +02:00
Tomasz Kapuściński b5e27c9f19 space() now returns a point with NaNs instead of the original position when it can't find free space 2022-07-09 16:48:59 +02:00
Tomasz Kapuściński ec425c768b Use the Y floor coordinate from topo() so it doesn't ignore spaceship's modified floor height 2022-07-09 16:47:59 +02:00
Tomasz Kapuściński 3fd9815138
Merge pull request #1507 from rasmusgo/find-space-on-spaceship
Find space on spaceship
2022-07-09 16:38:58 +02:00
Tomasz Kapuściński 3805851255 Made recolor a separate material attribute and added more color types 2022-07-09 12:23:50 +02:00
Tomasz Kapuściński a88d9cdd39 Implemented shader-side recoloring in HSV and added more material tags 2022-06-18 22:18:25 +02:00
Tomasz Kapuściński 7d31b1e55d Added missing include 2022-05-08 18:31:48 +02:00
Tomasz Kapuściński 56e0c915b5 Cleanup in texture structures and enums, added wrap mode to TextureCreateParams and fixed wrap mode in foreground texture (lens flare effect) 2022-05-08 18:23:37 +02:00
Tomasz Kapuściński a25ce2d5df Rewritten particle rendering, now uses its own vertex type for optimization 2022-05-08 16:22:20 +02:00
Tomasz Kapuściński cac34e259b Cleanup to reduce includes of device.h header file 2022-05-02 20:59:44 +02:00
Tomasz Kapuściński 2a529ae07f More cleanup 2022-05-02 19:22:50 +02:00
Tomasz Kapuściński a1e4e4b97c Minor cleanup 2022-05-02 19:10:26 +02:00
Tomasz Kapuściński 3b4c2f3049 Cleanup in OpenGL implementation
* Changed main directory to opengl33
* Put all remaining renderer classes into separate files
* Added missing license headers
2022-05-02 11:08:33 +02:00
Tomasz Kapuściński f2cc131ff7 Merge branch 'dev' into dev-graphics-overhaul
# Conflicts:
#	.github/workflows/build.yml
2022-05-02 09:24:05 +02:00
Tomasz Kapuściński b6f2a9e544
Fix for invisible batteries (code by melex750) (#1520)
* Fix for invisible batteries (code by melex750)

* Updated vcpkg

* A workaround for sprintf define

* Added mpg123 to dependencies due to newer version of SndFile

* Removed CONFIG

* Another fix for dependencies

* Made additional dependencies optional
2022-04-29 00:02:04 +02:00
Tomasz Kapuściński daa9419557 Merge branch 'dev' into dev-graphics-overhaul
# Conflicts:
#	src/level/player_profile.cpp
#	src/object/task/taskgoto.cpp
#	src/object/task/taskgoto.h
#	src/ui/mainui.cpp
2022-04-23 11:48:09 +02:00
Tomasz Kapuściński 0882b69ec8 Switch to gcc-9 for Ubuntu 18.04 builds for proper support of C++17 with filesystem 2022-04-23 11:34:15 +02:00
Tomasz Kapuściński 013d3cccf4 Changed team recolor to replace material albedo color instead of multiply by it for design convenience 2022-04-23 10:53:25 +02:00
Tomasz Kapuściński 8f710a24c8 Added proper conversion from sRGB to linear space and added a temporary fix for Blender bug with vertex colors in sRGB 2022-04-23 10:50:53 +02:00
Tomasz Kapuściński 7135a6660b Replaced error messages with Logger 2022-04-23 10:48:35 +02:00
Tomasz Kapuściński 7664594b8e Added constructor and conversion between linear space and sRGB 2022-04-23 10:46:38 +02:00
Tomasz Kapuściński 07541d0bbb
Merge pull request #1517 from SpaceManiac/patch/gitmodules-https
Use https URLs for git submodules
2022-04-23 10:35:04 +02:00
Tad Hardesty 8fb0f76f6f Use https URLs for git submodules 2022-04-08 19:22:39 -07:00
Tomasz Kapuściński 640cde1653 Various improvements and fixes
* Added strength parameter for ambient occlusion
* Added proper support for material and emissive textures
* Added team-based recoloring, uses "team" tag
* Changed shadow ranges to make close-up shadows much better
* Fixed background coloring
* Added proper defaulting for glTF values
* Fixed parsing of emissive values
* Added normalization of normals in vertex shaders of object and terrain renderers
2022-04-07 01:11:23 +02:00
Tomasz Kapuściński 4b1b1763df Removed extensions from model filenames to let the game load alternatives when available 2022-03-12 23:34:46 +01:00
Tomasz Kapuściński 829c5fb42f Added support for glTF 2.0 model format 2022-03-12 23:31:32 +01:00
Tomasz Kapuściński fd3c2af358 A proper fix? 2022-03-11 23:33:21 +01:00
Tomasz Kapuściński 5c2c52ad31 Fix for missing <filesystem>? 2022-03-11 23:16:50 +01:00
Tomasz Kapuściński aa3efd5841 Simplified model I/O, uses filename extensions to figure out format 2022-03-11 22:40:50 +01:00
Tomasz Kapuściński 920a4c3fc8 Split model I/O to separate files based on model format and removed new binary format 2022-03-11 21:06:40 +01:00
Tomasz Kapuściński d57370578f Disabled convert_model tool 2022-03-11 20:48:55 +01:00
Tomasz Kapuściński 4a16ee76a1 Partially refactored model and mesh structures 2022-03-11 19:49:03 +01:00
Tomasz Kapuściński 7af32caec2 Changed path type from std::string to std::filesystem::path in CInputStream, CInputStreamBuffer, COutputStream and COutputStreamBuffer 2022-03-11 17:46:24 +01:00
Tomasz Kapuściński 2d9db9c90a Refactored lighting in terrain renderer and rewritten drawing terrain to include all PBR properties 2022-03-09 20:47:44 +01:00
Tomasz Kapuściński d7a22bf74c Removed explicit from Color constructor 2022-03-09 17:08:51 +01:00
Tomasz Kapuściński 1a7346b845 A couple of fixes for rendering states 2022-03-09 16:59:23 +01:00
Tomasz Kapuściński 8c40b7c753 Force buffer orphaning to fix initial buffer binding 2022-03-09 16:56:03 +01:00
Rasmus Brönnegård fdc1792932 Let space() find points on the spaceship 2022-03-07 00:02:08 +01:00
Rasmus Brönnegård 483a855848 Add DistanceSquared to vector.h 2022-03-07 00:00:19 +01:00
tomangelo 4541db7f21
Merge pull request #1498 from rasmusgo/dev-loadgame-arg
Load game from command line
2022-03-06 23:05:04 +01:00
tomangelo 86d8ee4c38
Merge pull request #1496 from rasmusgo/fix-spelling
Fix spelling
2022-03-04 16:28:32 +01:00
MrSimbax 73db861cc6 Update data submodule 2022-03-01 17:35:57 +01:00
tomangelo 061ef44def
Merge pull request #1499 from rasmusgo/dev-better-goto
Better goto
2022-02-28 22:16:37 +01:00
Tomasz Kapuściński dffb988798 Added checkout submodule for docs 2022-02-26 22:32:00 +01:00
Tomasz Kapuściński d09c5da493 Checkout json submodule 2022-02-26 21:47:22 +01:00
Tomasz Kapuściński c011e49112 Another fix 2022-02-26 21:42:09 +01:00
Tomasz Kapuściński 628567701a Added nlohmann json as submodule 2022-02-26 21:12:40 +01:00
Tomasz Kapuściński 38990e283b Another fix 2022-02-26 20:04:13 +01:00
Tomasz Kapuściński fa5e229015 Fixed forward declaration of enums 2022-02-26 19:44:49 +01:00
Tomasz Kapuściński 05163c09a1 Fix for dependencies 2022-02-26 19:04:04 +01:00
Tomasz Kapuściński 8533be8d5c Replaced MakeUnique and MakeUniqueArray with std::make_unique 2022-02-26 18:48:51 +01:00
Tomasz Kapuściński 89551c83cf Merge branch 'dev' into dev-graphics-overhaul
# Conflicts:
#	src/graphics/engine/text.cpp
#	src/graphics/engine/text.h
#	src/script/scriptfunc.cpp
2022-02-26 04:43:56 +01:00
Tomasz Kapuściński 3001927576 Removed engine.h from includes in header files, replaced by forward declarations and includes in source files 2022-02-26 03:53:39 +01:00
Tomasz Kapuściński baa616050a Some refactors to reduce extensive recompilation cascades
Renamed AlphaMode::OPAQUE to AlphaMode::NONE due to clash with preprocessor define
Moved Gfx::EngineTriangle to a separate file
2022-02-26 02:39:13 +01:00
Tomasz Kapuściński e839f0dec7 Extended Material structure with PBR material attributes and added some of them to object renderer
Moved PBR lighting calculations to a separate shader source file
Removed some unused stuff
2022-02-26 01:16:36 +01:00
Tomasz Kapuściński 3168bf4350 Small cleanup 2022-02-25 21:07:01 +01:00
Tomasz Kapuściński 6447304531 Added nlohmann-json library to dependencies 2022-02-25 20:41:45 +01:00
Mateusz Przybył 6aebf60300
Merge pull request #1487 from pestoffne/fix/editor-input-utf8
Fixed input of long UTF-8 symbols in editor (#1423)
2022-02-25 17:09:27 +01:00
Rasmus Brönnegård 0829cd84fe goto: Remove unused BEAM_ACCURACY 2022-02-17 23:58:32 +01:00
Rasmus Brönnegård 8af600692e goto: Reduce NB_ITER back to 200 2022-02-17 23:40:07 +01:00
Rasmus Brönnegård 3478ee322b goto: Find a more exact end of path wrt goalRadius
The last segment of the path is shortened to avoid going too close
and risk bumping into the object that it was meant to approach.

The same position could also be found by finding the roots of a second
order polynomial analytically but this solution is simple and sufficient.
2022-02-15 22:46:30 +01:00
Evgeny Pestov 550d0f915b Use std::out_of_range in Utf8CharSizeAt 2022-02-14 18:33:41 +07:00
Evgeny Pestov d9e26c2516 Use std::invalid_argument in Utf8CharSizeAt 2022-02-14 18:23:44 +07:00
Evgeny Pestov 4bce63e38d Use 0b instead of 0x and check 1-byte prefix first in Utf8CharSizeAt
1-byte symbols is more common then 4-bytes symbols.
So checking 1-byte prefix first is more efficient.
2022-02-14 18:09:08 +07:00
Evgeny Pestov ec8a09e4a9 Merge commit '3405c03' into fix/editor-input-utf8 2022-02-14 17:57:30 +07:00
Evgeny Pestov 05b68a4b80 Refactor: Create function isUtf8ContinuationByte 2022-02-14 17:56:34 +07:00
Tomasz Kapuściński c378009128 Feature-breaking refactors
* Partially filled Material structure, currently only base attributes
* Removed recoloring of textures and team variants
* Removed one base object tier in engine structures
* Removed EngineRenderState
* Rewritten some code to better coding style
2022-02-13 00:03:46 +01:00
Rasmus Brönnegård 2d794d1a32 goto: Handle oversized costs with a special bucket
This is a bit redundant because the current usage of goto
does not trigger it. It can be triggered by:
* increasing goalRadius
* decreasing NUMQUEUEBUCKETS
* decreasing BM_DIM_STEP
* increasing edge costs
2022-02-12 23:35:58 +01:00
Rasmus Brönnegård e38835cfd4 goto with A-star (with bucket queue) 2022-02-12 23:35:58 +01:00
tomangelo2 e3ba1a1840 Fix compilation errors on MacOS 2022-02-10 19:46:50 +01:00
tomangelo2 08f6c32551 Update Homebrew installation command 2022-02-09 20:43:35 +01:00
Rasmus Brönnegård 2b8d580355 goto with Dial's algo (Dijkstra's + bucket sort) 2022-02-08 21:14:17 +01:00
Rasmus Brönnegård ee390bc270 LoadFinishedLevels if needed in LoadScene 2022-02-08 20:02:56 +01:00
Rasmus Brönnegård 14e7cd0e52 Rename loadgame to loadsave 2022-02-08 14:17:11 +01:00
tomangelo 6d8a52eb15
Merge pull request #1458 from lolbot-iichan/produce_teams
Add optional team parameter to produce() function
2022-02-07 16:34:19 +01:00
tomangelo 951db17d53
Merge pull request #1488 from colobot/dev-refactor-fonts-cache
Refactor fonts reloading
2022-02-07 15:24:10 +01:00
Tomasz Kapuściński 0d612b9928 Optimized text rendering 2022-02-05 21:07:25 +01:00
Tomasz Kapuściński aacc2d0596 Moved non-CRenderer-specific functionality back to CDevice and refactored some of the state change methods
Rewritten control rendering code to use improved way of sending geometry to GPU memory
2022-02-05 19:07:46 +01:00
Tomasz Kapuściński 074706e7ec Removed Vertex and VertexCol structures 2022-02-04 01:22:27 +01:00
Tomasz Kapuściński 1631b9587f Removed all DrawPrimitive*() methods from CDevice 2022-02-04 01:06:37 +01:00
Tomasz Kapuściński 750a470b9a Minor color refactors, added DrawPrimitives, rewritten remaining effect rendering 2022-02-04 01:00:18 +01:00
Tomasz Kapuściński 37bdc8665f Removed remaining rendering code from CGL33Device and fixed some issues 2022-02-03 20:53:53 +01:00
Tomasz Kapuściński cbf661f69f Disabled tests for light manager as it needs future refactoring 2022-02-03 19:35:30 +01:00
Tomasz Kapuściński d16144eee4 Added missing include and removed debugging calls 2022-02-03 18:55:46 +01:00
Tomasz Kapuściński 1a190b7f6f Partial refactor of UI rendering to improve performance and fix transparency issues
Disabled rendering via CDevice
2022-02-03 18:40:58 +01:00
Rasmus Brönnegård a7b294025e Rename BeamSearch to PathFindingSearch etc 2022-02-02 20:26:05 +01:00
Rasmus Brönnegård e2d4dd6995 Use ray tracing algorithm in BitmapTestLine 2022-02-02 20:26:05 +01:00
Rasmus Brönnegård d9f3078396 Replace beam search with breadth-first search 2022-02-02 20:26:05 +01:00
Tomasz Kapuściński 0908e10ff6 Removed material, lighting, fog and shadowing code from CDevice 2022-02-02 19:09:38 +01:00
Tomasz Kapuściński 7d9badb542 Added UV transform and rewritten animated texture mapping code to use it 2022-02-02 18:13:21 +01:00
Tomasz Kapuściński 3bd4fee844 Merge branch 'dev' into dev-graphics-overhaul
# Conflicts:
#	src/graphics/engine/camera.cpp
#	src/object/auto/autonuclearplant.cpp
#	src/object/auto/autopowerplant.cpp
#	src/object/interface/powered_object.h
#	src/object/motion/motionvehicle.cpp
#	src/object/old_object.cpp
#	src/object/old_object.h
#	src/object/task/taskmanip.cpp
#	src/object/task/taskmanip.h
#	src/object/task/tasktake.cpp
2022-02-02 18:11:06 +01:00
tomangelo 3405c038c9
Merge pull request #1495 from rasmusgo/numpad
Add workaround for numpad home/end keys etc
2022-02-02 16:45:14 +01:00
Rasmus Brönnegård 3400a0fab0 Add -loadgame argument to load game on start 2022-02-02 11:01:57 +01:00
Emxx52 85dc3f68e7
Merge pull request #1497 from colobot/dev-fix-recharging
Fix assert fail after PR#1444
2022-01-30 21:21:16 +01:00
tomangelo2 eff8e885d5 Fix assert fail after PR#1444 2022-01-30 20:40:04 +01:00
tomangelo cbc07c04a5
Merge pull request #1444 from immibis/slotted-object
Slotted object interface
2022-01-29 17:20:36 +01:00
tomangelo2 0003494c9e Merge PR #1444 2022-01-29 17:16:57 +01:00
Tomasz Kapuściński 741d5c75ba Refactored shadow framebuffer creation and binding 2022-01-24 23:16:22 +01:00
Tomasz Kapuściński 2ff722eee6 Refactored or removed some of the unused CDevice features 2022-01-24 22:29:39 +01:00
Tomasz Kapuściński 39b6621463 Renamed transparency to ghost mode 2022-01-24 21:57:56 +01:00
Tomasz Kapuściński 9a07c1d858 Refactored background, cloud and planet rendering, fixed shadow settings 2022-01-24 21:50:45 +01:00
Rasmus Brönnegård 19ae57c9ad Fix spelling of appearance 2022-01-24 19:56:47 +01:00
Rasmus Brönnegård 6e0207ca5e Fix spelling in app and main 2022-01-24 19:47:07 +01:00
Rasmus Brönnegård be8d37241a Add workaround for numpad home/end keys etc 2022-01-23 13:16:13 +01:00
Tomasz Kapuściński e76c00c7f4 Fixed the Z coordinate not working in particle renderer 2022-01-22 01:50:10 +01:00
Tomasz Kapuściński cba70fc912 Added DrawPrimitive() to CObjectRenderer and used it for rendering water 2022-01-22 00:57:00 +01:00
Tomasz Kapuściński 048393f448 Added CParticleRenderer and reimplemented particle rendering code to use it 2022-01-20 21:38:58 +01:00
Tomasz Kapuściński 710f448477 Partially fixed rendering of models in front of the interface (e.g. profile screen) 2022-01-19 23:14:03 +01:00
Tomasz Kapuściński 367dab9c5a Cleanup in vertex structures 2022-01-19 22:22:59 +01:00
Tomasz Kapuściński c280924c0e Removed Gfx::VertexTex2 2022-01-19 21:33:53 +01:00
Tomasz Kapuściński 5dacb82b22 Partial refactor of model I/O
* Mostly removed legacy Gfx::Material usage
* Bake legacy diffuse color to vertex color
* Removed code that writes to old model formats
2022-01-19 19:46:39 +01:00
Tomasz Kapuściński a54a59146d Corrected transparency mode 2022-01-19 17:14:27 +01:00
Tomasz Kapuściński a1ea633a3e Refactored EngineTextureMapping into enum class 2022-01-18 20:14:07 +01:00
Tomasz Kapuściński 68a222e03a Refactored EngineShadowType to enum class 2022-01-18 19:42:19 +01:00
Tomasz Kapuściński 67bd982969 Refactored EngineTriangleType into enum class 2022-01-18 19:29:36 +01:00
Tomasz Kapuściński d9073de251 Removed unnecessary tests and include 2022-01-05 21:08:28 +01:00
Tomasz Kapuściński 754684bfe9 Refactored MatrixVectorMultiply(), added TransformDivide() for cases where perspective divide is needed 2022-01-05 19:22:57 +01:00
Tomasz Kapuściński 9c37f6cbd5 Fully refactored Math::Matrix, removed matrix.h and moved remaining functions to other files 2022-01-05 19:12:35 +01:00
Tomasz Kapuściński 208f142cd2 Made Math::Matrix an alias to glm::mat4, partial refactors 2022-01-05 00:35:41 +01:00
Tomasz Kapuściński e5d8e2b428 Fixed compilation error 2022-01-04 21:45:10 +01:00
Tomasz Kapuściński 0bba168f94 Removed vector.h, refactored redundant functions and moved remaining ones to func.h 2022-01-04 20:43:36 +01:00
Tomasz Kapuściński db3b1d74d1 Refactored unnecessary Normalize, DotProduct, CrossProduct and Clamp functions 2022-01-04 02:10:36 +01:00
Tomasz Kapuściński 50fe905455 Removed Math::Vector alias and refactored remaining uses of it 2022-01-04 01:39:55 +01:00
Tomasz Kapuściński d5e8cfd4ba Refactored Math::Vector to glm::vec3 in object task classes 2022-01-04 01:18:46 +01:00
Tomasz Kapuściński ffe1815ec9 Refactored Math::Vector to glm::vec3 in object motion classes 2022-01-04 01:05:24 +01:00
Tomasz Kapuściński 2690d04f64 Refactored Math::Vector to glm::vec3 in object interface and object subclass classes 2022-01-04 00:52:07 +01:00
Tomasz Kapuściński 3707daf678 Refactored Math::Vector in object implementations 2022-01-04 00:16:59 +01:00
Tomasz Kapuściński 076dce6981 Refactored Math::Vector in CScriptFunctions 2022-01-04 00:11:20 +01:00
Tomasz Kapuściński d6d74f200b Refactored Math::Vector in convert_model tool 2022-01-04 00:03:57 +01:00
Tomasz Kapuściński 1a7ffa693b Refactored Math::Vector in remaining UI classes 2022-01-04 00:01:54 +01:00
Tomasz Kapuściński dbe127569b Refactored Math::Vector in control classes 2022-01-03 23:55:50 +01:00
Tomasz Kapuściński da2471567d Refactored Math::Vector in sound implementation 2022-01-03 23:53:22 +01:00
Tomasz Kapuściński 55f5d25c95 Refactored Math::Vector to glm::vec3 in remaining auto classes 2022-01-03 23:48:38 +01:00
Tomasz Kapuściński 4634564f17 Refactored Math::Vector to glm::vec3 in various auto classes 2022-01-03 23:32:30 +01:00
Tomasz Kapuściński 300a2d8569 Refactored Math::Vector to glm::vec3 in CrashSphere, CObjectFactory, old_object.h, old_object_interface.h 2022-01-03 22:51:36 +01:00
Tomasz Kapuściński b4bfb8b242 Refactored Math::Vector in CLevelParserParam, CObjectCondition and CScoreboard 2021-12-29 02:19:22 +01:00
Tomasz Kapuściński 6277e10b3f Refactored Math::Vector in CParticle, CPlanet, CPyro, CTerrain, CText, CWater, ModelInput and few structures 2021-12-29 01:55:48 +01:00
Tomasz Kapuściński 47ad390f1d Refactored Math::Vector in CCamera, CLightManager, CLightning, CMainMovie, glutil.h and geometry.h 2021-12-29 00:08:02 +01:00
Tomasz Kapuściński d25d6124a9 Changed Math::Vector into alias to glm::vec3 2021-12-28 23:01:30 +01:00
Tomasz Kapuściński 70151279f6 Removed Math::Point and minor refactor 2021-12-24 20:44:54 +01:00
Tomasz Kapuściński 431416d75e Refactored Math::Point in CEngine 2021-12-24 20:25:38 +01:00
Tomasz Kapuściński 77c6f8e54f Refactored Math::Point in CRobotMain, CObjectFactory, CBaseBuilding, CAutoInfo, CScript, CDebugMenu, CDisplayText and CObjectInterface 2021-12-24 20:08:04 +01:00
Tomasz Kapuściński dc99e19ed9 Refactored Math::Point in CPhysics, CDisplayInfo, CFileDialog, CMainDialog, CMainMap, CMainShort and CStudio 2021-12-24 19:02:25 +01:00
Tomasz Kapuściński c659e060c1 Refactored Math::Point in task classes 2021-12-24 18:39:45 +01:00
Tomasz Kapuściński f8f3a64612 Refactored Math::Point in motion classes 2021-12-24 18:32:42 +01:00
Tomasz Kapuściński 7bf37a3999 Refactored Math::Point in screen classes 2021-12-24 03:53:36 +01:00
Tomasz Kapuściński 3fabdad1fe Refactored Math::Point in CSettings, CParticle, CPyro, CInterface, CMainUserInterface and CScreen 2021-12-24 03:45:59 +01:00
Tomasz Kapuściński a806bb2657 Refactored Math::Point in auto classes 2021-12-24 03:26:25 +01:00
Tomasz Kapuściński 91c19bff55 Refactored Math::Point in control classes 2021-12-24 03:18:10 +01:00
Tomasz Kapuściński 9691974b1a Refactored Math::Point in CLighting, CParticle, CParticleGenerator and CText 2021-12-24 02:36:54 +01:00
Tomasz Kapuściński 07d3d79e8d Refactored Math::Point in CPlanet, CTerrain, CWater and CLevelParserParam 2021-12-24 02:04:15 +01:00
Tomasz Kapuściński 498f15cc92 Refactored Math::Point in CApplication, CInput, CCamera, CCloud and Event 2021-12-24 01:38:54 +01:00
Tomasz Kapuściński b36ec266f0 Refactored Math::Point from vertex types 2021-12-24 00:57:04 +01:00
Tomasz Kapuściński c0d067d24b Changed Math::Point into alias to glm::vec2, minor refactors 2021-12-24 00:11:12 +01:00
Tomasz Kapuściński 12c0f41477 Removed unused null renderer files
Null renderer will be rewritten entirely anyway, no need to keep these files in their current form.
2021-12-23 23:40:34 +01:00
Tomasz Kapuściński f7c66741c6 Removed Math::IntPoint 2021-12-23 23:38:26 +01:00
Tomasz Kapuściński 60deb0328a Refactored Math::IntPoint in CInput and CImage 2021-12-23 23:36:30 +01:00
Tomasz Kapuściński 0ef4579da8 Refactored Math::IntPoint in CApplication and various classes 2021-12-23 23:26:08 +01:00
Tomasz Kapuściński 55c692e8bb Refactored Math::IntPoint in CEngine and CParticle 2021-12-23 23:08:56 +01:00
Tomasz Kapuściński 835f84584e Refactored Math::IntPoint in CTerrain 2021-12-23 22:47:44 +01:00
Tomasz Kapuściński bd2ad39f6a Refactored Math::IntPoint in CText 2021-12-23 22:47:15 +01:00
Tomasz Kapuściński 48d2b4a618 Refactored Math::IntPoint in core graphics classes 2021-12-23 22:35:28 +01:00
Tomasz Kapuściński cd6ea1a4c5 Changed Math::IntPoint into alias to glm::ivec2 2021-12-23 22:09:58 +01:00
MrSimbax 4ecfb47f07 Fix MSVC errors 2021-12-21 18:01:42 +01:00
MrSimbax d3dd99c384 Refactor fonts reloading
* Remove hardcoded default font name.
  This means the `fonts/fonts.ini` file is now mandatory
  and must contain definition of all 9 font types.
  Old mods relying on an incomplete `fonts.ini` file might break.
  A separate PR creating the required `fonts/fonts.ini` file
  should be merged before this pull request.
* Simplify `CFontLoader`.
    * Return `std::optional` instead of returning a default.
    * Remove the now unnecessary `std::map`s.
    * Remove the now unnecessary `GetFontType` method.
* Improve Gfx::FontType.
    * Provide `ToString` function for the enum, which is now
      used for logs and by `CFontLoader`.
    * Provide `ToBoldFontType` and `ToItalicFontType` functions.
    * Replace hex literals with binary literals for readability.
* Move font caching related code to a new private class `FontsCache`.
    * Add neccessary changes because of changes made in `CFontLoader`.
    * Add minor code improvements like renames and formatting.
    * Split the code into smaller functions for readability.
    * Simplify the `CText` class.
* Apply the rule of 5 to the `CachedFont` structure.
2021-12-21 00:50:36 +01:00
Evgeny Pestov 69ea470a26 CEdit::MoveChar never moves cursor between bytes of one UTF-8 symbol 2021-12-17 00:54:44 +07:00
Evgeny Pestov 65da4c42c4 CEdit::DeleteOne expands selection to delete integer number of UTF-8 symbols 2021-12-17 00:54:38 +07:00
Evgeny Pestov cd059bd511 Show questions instead of crushing in case of UTF-8 errors 2021-12-17 00:54:30 +07:00
Mateusz Przybył 53053b901f
Merge pull request #1483 from colobot/dev-cbot-io-tests-refactor
Refactor CBotUT.TestSaveStateIoFunctions
2021-12-15 18:00:34 +01:00
Mateusz Przybył 17f68efb81
Merge pull request #1481 from colobot/dev-minor-fixes
Some minor technical fixes
2021-12-15 17:59:54 +01:00
Tomasz Kapuściński 98ad26da3d Changed glm::identity to explicit construction 2021-12-15 00:20:56 +01:00
Tomasz Kapuściński 36ac6d9956 Another fix 2021-12-15 00:09:47 +01:00
Tomasz Kapuściński 1eb17b2fa1 Added includes to fix compilation errors for older versions of glm 2021-12-14 23:56:24 +01:00
Tomasz Kapuściński 33744de372 Add target alias for older versions of glm 2021-12-14 23:42:14 +01:00
Tomasz Kapuściński d651b36eb2 Corrected includes 2021-12-14 23:09:20 +01:00
Tomasz Kapuściński 7e0db31cc1 Merge branch 'dev' into dev-graphics-overhaul 2021-12-14 22:27:43 +01:00
Tomasz Kapuściński c389156499 Added commands for controling triplanar mapping 2021-12-14 21:58:23 +01:00
Tomasz Kapuściński 0207669d61 Added optional triplanar mapping mode for the secondary texture 2021-12-14 21:54:19 +01:00
Tomasz Kapuściński b158318e83 Possibly a fix for most transparency issues 2021-12-14 21:51:29 +01:00
Tomasz Kapuściński 11bfcc6d53 Fix resetting bound textures 2021-12-14 21:50:26 +01:00
Evgeny Pestov 9269a55e8b Fixed input of long UTF-8 symbols in editor (#1423) 2021-12-14 23:06:37 +07:00
Tomasz Kapuściński 2583f6fe36 Removed UIRenderer's DrawPrimitive() via CDevice 2021-12-12 21:17:39 +01:00
MrSimbax 193d105a3f Refactor CBotUT.TestSaveStateIoFunctions
Split the test into several parametrised tests for each data type.

Add more tests with different values.

Fix the ReadBinary() function in order to fix the ReadDouble() function
for negative values (the sign bit was being lost).
2021-12-09 20:44:31 +01:00
MrSimbax ea7837b4c6 Remove usage of a CMake 3.17 feature
We currently use CMake 3.16 for compatibility with Ubuntu 18.04 LTS.

The `NAME_MISMATCHED` argument which turns off a CMake warning
when using `FIND_PACKAGE_HANDLE_STANDARD_ARGS`, is not available
in CMake 3.16 and can prevent a successful build.

See
https://github.com/colobot/colobot/pull/1478#issuecomment-986204233
2021-12-08 19:35:30 +01:00
MrSimbax f9c275919e Fix CMake warning about empty GoogleTest version
The warning appeared when GoogleTest is used as a submodule.
2021-12-08 19:25:36 +01:00
MrSimbax 38b9b9be4c Update data, gtest and add options to .gitmodules
Update the `data` and `lib/googletest` submodules.

`git submodule update --remote` command should now
update the data submodule by rebasing on the remote branch named
the same as the current branch.

Changes in the `lib/googletest` submodule should now be ignored
in `git status`.
2021-12-08 19:15:16 +01:00
MrSimbax 9fd935770a Fix CBotUT.TestSaveStateIOFunctions
Fail occurred due to wrong read of min double.
`unsigned long` has been changed in Write/ReadDouble functions to
`uint64_t`.
`unsigned int` has been changed in Write/ReadFloat functions to
`uint32_t`.

According to the standard
`int` is at least 16-bit so it might be too small for 32-bit `float`,
`long` is at least 32-bit so it might be too small for 64-bit `double`,
and `long long` is at least 64-bit.
2021-12-05 16:51:51 +01:00
Tomasz Kapuściński d1489a1fb1 Removed ShadeModel 2021-12-05 13:01:12 +01:00
Tomasz Kapuściński 0568fcdb81 Refactored FillMode to enum class 2021-12-05 12:53:31 +01:00
Tomasz Kapuściński 39c837d323 Refactored PrimitiveType to enum class 2021-12-05 12:26:34 +01:00
tomangelo 3aa7c3c2e0
Stop handling compilation warnings as errors (#1477)
* Stop handling compilation warnings as errors

* Restore mistakenly removed flag
2021-12-05 11:51:28 +01:00
Tomasz Kapuściński 7a555e19c4 Fix in convert_model tool 2021-12-04 16:04:53 +01:00
Tomasz Kapuściński 26c0d85c66 Updated cache key 2021-12-04 16:02:17 +01:00
Tomasz Kapuściński 613efd7599 Added missing glm library to CI 2021-12-04 15:31:16 +01:00
Mateusz Przybył ae179d9005
Merge pull request #1440 from melex750/dev-insect-from-egg
Fix saving/loading programs for insects from AlienEgg
2021-12-04 10:04:49 +01:00
Mateusz Przybył 96fece4e6d
Merge pull request #1464 from nipsufn/master
fix SatCom content offset on screens with high resolution / small font size
2021-12-04 10:01:53 +01:00
Tomasz Kapuściński 9139239f9f Merge branch 'dev' into dev-graphics-overhaul
# Conflicts:
#	src/app/app.cpp
#	src/graphics/opengl/gl14device.cpp
#	src/graphics/opengl/gl14device.h
#	src/graphics/opengl/gl21device.cpp
#	src/graphics/opengl/gl21device.h
2021-12-01 17:27:54 +01:00
Tomasz Kapuściński 57502d2f54 Added object renderer (WIP)
Rewritten shadow rendering logic
Split some shaders into smaller parts
Shadow renderer now has its own framebuffer object
2021-12-01 17:05:20 +01:00
Tomasz Kapuściński ce71f25901 Removed unused shader files 2021-10-25 21:42:19 +02:00
Tomasz Kapuściński fea6b87139 Added fog to terrain renderer and renamed variables 2021-10-17 16:27:29 +02:00
Tomasz Kapuściński 4157604458 Added shadow renderer and removed rendering modes 2021-10-17 16:05:20 +02:00
nipsufn 117c72ba72 fix SatCom content offset on high resolution / small font size 2021-09-29 15:26:19 +02:00
Tomasz Kapuściński 79d4cd9060 Updated TerrainRenderer
* Engine will now use it to render terrain
* Added directional light source
* Added dynamic shadows
* Moved visibility computation to CEngine
* Removed uniform buffers
2021-09-19 20:08:31 +02:00
Mateusz Przybył 1438438937
Merge pull request #1462 from colobot/dev-update-license
Update license headers
2021-09-11 16:10:44 +02:00
MrSimbax 80f074e2ba Update license headers 2021-09-11 15:53:59 +02:00
MrSimbax 171bba1bcd Rewrite the update license script
The old script duplicated license headers for me, instead of
updating them.
2021-09-11 15:53:50 +02:00
Mateusz Przybył 95579bbf1d
Merge pull request #1461 from colobot/AbigailBuccaneer-platform-independent
Merge PR#1141 "Use C++11 threading and timing constructs"
2021-09-11 14:23:09 +02:00
MrSimbax c9dca4cebd Rename SystemDialogType::ERROR to ERROR_MSG
Unfortunately, the ERROR name collides with
a preprocessor definition in windows.h
2021-09-11 13:40:22 +02:00
MrSimbax 6aa83c93ac Update data submodule 2021-09-11 13:29:03 +02:00
MrSimbax a69b88e09a Move time related functions out of CSystemUtils
GetCurrentTimeStamp() has not been moved because of
CApplication unit tests.
2021-09-11 13:26:38 +02:00
MrSimbax 5daaba6e64 Fixes after merge
Fix mistakes after previous merge and make it compile.

Rewrite the function interpolating between time stamps as it was
written after the original pull request was created. Add unit tests
for it.

I couldn't help myself and also changed some enums to enum classes and
did some renames.
2021-09-11 12:44:26 +02:00
MrSimbax 2b107736e2 Merge branch 'platform-independent' of https://github.com/AbigailBuccaneer/colobot into AbigailBuccaneer-platform-independent 2021-09-11 10:47:39 +02:00
Tomasz Kapuściński 30d688c1ec Added and implemented terrain renderer 2021-09-05 16:32:19 +02:00
Tomasz Kapuściński 58c75ce61a Added implicit conversion between Math::Matrix and glm::mat4 2021-09-05 16:32:18 +02:00
Tomasz Kapuściński 100be95113 Added CVertexBuffer and reimplemented vertex buffer management 2021-09-05 16:32:18 +02:00
Tomasz Kapuściński 5c037837f5 Added Vertex3D 2021-09-05 16:32:17 +02:00
Tomasz Kapuściński 12e696bf1c Added color and moved uniform data to uniform buffer block 2021-09-05 16:32:17 +02:00
Tomasz Kapuściński 55513703b2 Removed unused static buffer types 2021-09-05 16:32:16 +02:00
Tomasz Kapuściński f2eafd563e Removed interface rendering mode 2021-09-05 16:32:16 +02:00
Tomasz Kapuściński 16200bbeac Removed all dependency on interface rendering mode 2021-09-05 16:32:16 +02:00
Tomasz Kapuściński 465fe59dfb Added Renderers
Added UI Renderer
Added OpenGL 3.3 UI Renderer
Reimplemented most of UI drawing functionality to use UI Renderer
TODO: fix OpenGL errors
2021-09-05 16:32:15 +02:00
Tomasz Kapuściński 704e3f2f0d Improved code for loading and linking shaders 2021-09-05 16:32:15 +02:00
Tomasz Kapuściński fe02cf3e4b Added Vertex2D 2021-09-05 16:32:14 +02:00
Tomasz Kapuściński 5e7fb5010f Temporarily removed CNullDevice 2021-09-05 16:32:14 +02:00
Tomasz Kapuściński b322ce064b Added dependency on glm
# Conflicts:
#	src/CMakeLists.txt
2021-09-05 16:31:57 +02:00
Tomasz Kapuściński ec21faf15c Removed gl14 and gl21 devices 2021-09-05 16:25:38 +02:00
Mateusz Przybył e0c5ca962f
Merge pull request #1327 from MrJohn10/vscode-instructions
Add instructions for compilation and installation using vscode
2021-09-05 15:17:04 +02:00
Mateusz Przybył 37f82acff0
Merge pull request #1457 from vieux/master
system_macosx.cpp: fix typo
2021-09-05 14:40:32 +02:00
Mateusz Przybył c04d3ef50d
Merge pull request #1341 from colobot/dev-modern
Merge dev-modern into dev
2021-09-05 14:32:13 +02:00
MrSimbax 62b14bcf62 Bump C++ version from 11 to 17 2021-09-04 22:27:06 +02:00
MrSimbax 005f5b5103 Replace ::add-path:: function with appending to $GITHUB_PATH
See https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
2021-09-04 21:59:49 +02:00
MrSimbax bb6c32c897 Update run-vcpkg action from v3 to v7 2021-09-04 21:52:58 +02:00
MrSimbax 8299fe41bc Remove JenkinsFile as it's no longer used 2021-09-04 21:52:58 +02:00
MrSimbax d39f1999e7 Remove support for MXE 2021-09-04 21:52:58 +02:00
MrSimbax d06b7e1456 Update vcpkg version used in CI 2021-09-04 21:52:58 +02:00
MrSimbax 41cf9974f9 Bump CMake version from 3.17 to 3.16
See https://github.com/colobot/colobot/issues/1306#issuecomment-657096265
2021-09-04 21:51:55 +02:00
MrSimbax bbf5c806d8 Fix MSVC compilation due to macros in Windows API headers
There exists `CreateDirectory` `#define` somewhere and it results in
failed compilation of `resourcemanager.cpp`.
Similarly for `RemoveDirectory`. See
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createdirectorya

Rename the two methods to remove the conflict.

The fail occurs at least when using Visual Studio 2022 Preview.
2021-09-04 20:34:02 +02:00
MrSimbax 8f0b367f9c Find Opus because SndFile now depends on it 2021-09-04 20:33:15 +02:00
MrSimbax 65e12621ff Link brotli since freetype can now depend on it
The fixes are from PR #1371
2021-09-04 20:31:22 +02:00
MrSimbax 84d23e91ed Fix CMAKE_MSVC_RUNTIME_LIBRARY name for dynamic runtime 2021-09-04 20:29:52 +02:00
MrSimbax 5e37f84bc7 Merge branch 'dev' into dev-modern 2021-09-04 19:11:24 +02:00
Victor Vieux 11047ecd53 system_macosx.cpp: fix typo 2021-08-24 15:48:31 -07:00
lb_ii 91a290dade Assign team id to Alien eggs created during produce() 2021-08-25 01:09:58 +03:00
lb_ii ea62a449d4 Add optional team parameter to produce() function 2021-08-24 02:21:42 +03:00
Mateusz Przybył faa4eaae20 Release 0.2.0-alpha: Bump version 2021-08-21 22:57:34 +02:00
Mateusz Przybył c039e7e859 Post-release 0.2.0-alpha 2021-08-21 22:57:34 +02:00
Mateusz Przybył d9c966a95b Release 0.2.0-alpha: Merge branch 'dev' 2021-08-21 22:57:33 +02:00
MrSimbax 92f574d2ca Remove Ubuntu 16.04 from CI jobs 2021-08-21 22:48:51 +02:00
MrSimbax decab29555 Remove linter CI jobs
They require Ubuntu 16.04 which is no longer supported.
2021-08-21 22:48:51 +02:00
MrSimbax ecc23dfb3e Update data submodule 2021-08-21 22:18:52 +02:00
Fiftytwo a5d9bae052 Fix missing AmphibiousTrainer in drive_type 2021-08-20 18:17:36 +02:00
tomangelo c04291a55e
Update polish translation (#1407) 2021-08-16 18:01:08 +02:00
Emxx52 efad9a4dae
Merge pull request #1438 from melex750/dev-cbot-fix-leaks
CBOT bug fixes and improved performance
2021-08-14 20:15:58 +02:00
Emxx52 3ab153225a
Merge pull request #1439 from melex750/dev-cbot-repeat
Restore repeat(n) instruction in CBOT
2021-08-14 20:15:00 +02:00
immibis 76314f522f Slotted object interface 2021-07-04 21:50:56 +02:00
melex750 55d6c431f2 Fix a bug in WriteStream and ReadStream
Added a unit test to confirm reliability of I/O
functions used by SaveState and RestoreState.
2021-06-25 18:50:15 -04:00
melex750 ce450d1c00 Fix save/load programs for insects from AlienEgg
fixes #1370
2021-06-25 18:47:25 -04:00
melex750 9f5ee21bbe Restore repeat(n) instruction
fixes #1403
2021-06-11 23:28:53 -04:00
melex750 27466a4223 Make all CBotStack data members non-static 2021-06-11 22:48:50 -04:00
melex750 a279541198 Make all CBotCStack data members non-static 2021-06-11 22:47:33 -04:00
melex750 309f80b25f Fix some bugs and memory leaks in CBOT
* Added CBotStack::StackOver() calls where it was possible
  to go out-of-bounds when calling CBotStack::AddStack().
* Fixed some bugs in CBotExternalCallClass
2021-06-11 22:46:23 -04:00
melex750 993a6adf6e Fix inherited data members not being saved
* Removed erroneous 'parent instance' from CBotVarClass.
* Fixed output of CBVarClass::GetValString()
2021-06-11 22:44:20 -04:00
Emxx52 fabbdda964
Merge pull request #1406 from colobot/dev-gameplus
Add Missions+ gamemode, add new CBOT categories and functions, update Sniffers
2021-03-30 21:05:34 +02:00
Fiftytwo cdb63e2a8c Update data submodule 2021-03-30 20:51:17 +02:00
Fiftytwo 8647deafc8 Merge branch dev into dev-gameplus 2021-03-21 22:30:23 +01:00
Fiftytwo dbd9db86a6 Update data submodule 2021-03-21 22:10:42 +01:00
tomangelo b338b18f16
Merge pull request #1405 from colobot/dev-missing-library
Add missing library in MSYS2 instruction
2021-03-21 21:10:34 +01:00
tomangelo2 0b948b655e Add missing library in MSYS2 instruction 2021-03-21 15:17:28 +01:00
Mateusz Przybył 52446c1049
Merge pull request #1371 from jaladreips/dev-cmake
Fix MSVC building issues by correcting CMakeLists.txt
2021-02-22 20:49:27 +01:00
krzys_h fbbe25b25e
Merge pull request #1391 from colobot/dev-gh-actions
Fix uploading linter results from forks to GitHub
2021-02-22 19:09:35 +00:00
krzys-h f5519f8936
Send comment when pull request targets the wrong branch 2021-02-22 12:57:04 +01:00
krzys-h 9f2f7780a4
Safely upload linter results from forks to GitHub
This makes lint results from pull requests appear as GitHub checks
similarly to how pull requests from branches are able to work

Based on https://securitylab.github.com/research/github-actions-preventing-pwn-requests
2021-02-22 12:57:03 +01:00
krzys-h 9c91fd1e52
Replace custom download script with dawidd6/action-download-artifact 2021-02-22 10:44:45 +01:00
Mateusz Przybył 7b237ce9ad
Merge pull request #1387 from colobot/dev-fix-vsync
Remove vsync loop and improve vsync UI
2021-02-07 21:40:24 +01:00
MrSimbax 404d2dbeb1 Fix segfault in CApp UT
I moved m_engine creation to the constructor.
However, it is not complete until after calling m_engine->Create().
The UT segfault because the pointer is not null and destructor calls
m_engine->Destroy() on an incomplete object.
(Yes, UTs test incomplete SUT.)

So I moved back the m_engine creation to CApp::Create() but before
the SDL initialization as m_engine holds the flag for vsync.
2021-02-07 13:38:29 +01:00
MrSimbax 9a04685101 Fix compile error 2021-02-07 13:03:12 +01:00
MrSimbax a7aaa07356 Update vsync list after user interaction
The vsync may immediately fallback to another option after change from
the user so the UI should reflect that.

Todo: show a popup in UI informing the user why their desired vsync
option couldn't be set. Right now the error message is visible only from
the logs.
2021-02-07 12:50:13 +01:00
MrSimbax 71ff89a803 Remove vsync disable/enable loop (fix #1383)
Also a small refactor due to repeated code.
The vsync flag in m_engine is now synchronized with the SDL state
during initial configuration of CApp.
2021-02-07 12:47:32 +01:00
jakac c336a67afa Fix MSVC building issues by correcting CMakeLists.txt 2021-01-03 15:46:01 +01:00
Fiftytwo 10ec454f6b Fix Target research() executing in ResearchCenter 2020-12-31 05:00:33 +01:00
Mateusz Przybył d71ee4ef68
Merge pull request #1357 from colobot/dev-fix-satcom-crash-again
Fix crashes in SatCom on some \button characters
2020-09-21 16:55:30 +02:00
MrSimbax 05de2baef5 Fix crashes in SatCom on some \button characters
The issue is that the \button fragments in SatCom are replaced with
invalid UTF-8 bytes, hence those bytes need to be handled as a special
case when checking for UTF-8 character length.

When the text is processed e.g. in `Gfx::CText::Justify`, there are
generally two arrays: `text` and `format`. The second one is interpreted
as a font for a given character, e.g. `text[i]` has font `format[i]`.

Now, in the loops the index for `text` is increased by the length of
the character, e.g. 1 to 4 bytes, whereas index for `format` is
only incremented. It seems there's an assumption that `format` treats
multibyte characters as one byte, which doesn't seem to be true by
looking at the process of filling up the `format` array. This can result
in using wrong font e.g. FONT_SATCOM for the \button character which
should be FONT_BUTTON, hence the `StrUtils::Utf8CharSizeAt` method
complains about unexpected continuation byte via exception, causing
the crash.

Incrementing the index by the UTF-8 length seems to have fixed the
issue. However, I am not sure if I haven't broken anything else by this
and if I analyzed the intended behaviour correctly.
Gfx::CText needs a major refactor IMHO.
2020-09-20 21:22:05 +02:00
Mateusz Przybył f64c610fa4
Merge pull request #1354 from suve/gcc11-diagnostics-fix
GCC11 diagnostics fix (round 2)
2020-09-15 16:20:31 +02:00
Jeff Law ad2e3db92f Fix more dynamic casts for gcc-11
Signed-off-by: suve <veg@svgames.pl>
Jeff's patch was written for the 0.1.12 stable release.
Adapted to work with the "dev" branch (as of commit 13098ee).
2020-09-15 10:20:24 +02:00
Mateusz Przybył 13098ee378
Merge pull request #1351 from suve/gcc11-diagnostics-fix
GCC11 diagnostics fix
2020-09-11 20:37:25 +02:00
MrSimbax 8fdf79958f Merge branch 'master' of https://github.com/ccao001/colobot into dev-add-guix
Fixed merge conflict
2020-09-11 19:16:00 +02:00
Jeff Law 8c6ac4cd16 Fix dynamic casts to avoid gcc-11 diagnostics 2020-09-04 11:16:45 +02:00
tomangelo 2685a1eb60
Add cell capacity parameters (#1348) 2020-08-31 13:37:45 +02:00
ccao001 a54a117ba4
README: Add Guix
GNU Guix is a transactional package manager and an advanced distribution of the GNU system that respects user freedom. Guix can be used on top of any system running the kernel Linux, or it can be used as a standalone operating system distribution for i686, x86_64, ARMv7, and AArch64 machines.

In addition to standard package management features, Guix supports transactional upgrades and roll-backs, unprivileged package management, per-user profiles, and garbage collection. When used as a standalone GNU/Linux distribution, Guix offers a declarative, stateless approach to operating system configuration management. Guix is highly customizable and hackable through Guile programming interfaces and extensions to the Scheme language.
2020-08-30 00:44:45 -04:00
Emxx52 a4cfe616a8
Merge pull request #1349 from colobot/dev-fix-abs
Fix warning regarding mismatched parameter types
2020-08-27 00:53:45 +02:00
tomangelo2 f08c67bef9 Fix warning regarding mismatched parameter types 2020-08-27 00:28:03 +02:00
Emxx52 b17a4391b0
Merge pull request #1336 from colobot/dev-mod-manager
Add Mod Manager
2020-08-21 18:43:45 +02:00
Emxx52 1c9f5f3f64
Merge branch 'dev' into dev-mod-manager 2020-08-21 18:21:08 +02:00
Fiftytwo 68c254c101 Update data submodule 2020-08-21 18:09:28 +02:00
tomangelo d7ec891ab8
Merge pull request #1346 from melex750/dev-cbot-fix-delete
Fix CBOT script hanging at delete()
2020-08-20 22:09:37 +02:00
tomangelo dbc13bad20
Merge pull request #1345 from melex750/dev-cbot-fix-abs
Fix abs() only working on floats
2020-08-17 19:28:35 +02:00
tomangelo d2c8888067
Merge pull request #1344 from colobot/dev-suppress-fonts-warning
Remove unnecessary warning if there is no fonts.ini file
2020-08-17 19:27:59 +02:00
melex750 8d5cafecb3
Fix CBOT script hanging at delete() 2020-08-15 09:41:31 -04:00
melex750 d0961a517a
Fix abs() only working on floats 2020-08-15 09:29:45 -04:00
Fiftytwo 4c1d3eecd1 Add flag() and deflag() CBOT functions 2020-08-15 03:31:17 +02:00
Fiftytwo 56c99e741e Make Vault buildable 2020-08-08 20:51:56 +02:00
tomangelo2 4bb6f9f1b3 Remove unnecessary warning if there is no fonts.ini file 2020-08-08 15:41:07 +02:00
Fiftytwo b9305dfd45 Fix Mushroom SatCom links 2020-08-08 14:34:21 +02:00
Mateusz Przybył 5749fff377
Merge pull request #1342 from colobot/dev-lighting-fix
Fixes lighting issues and mipmapping
2020-08-03 20:48:15 +02:00
Tomasz Kapuściński 4c14050b27 Fixed mipmaps being outdates after texture update. 2020-07-31 22:04:47 +02:00
Tomasz Kapuściński 33b7c893cb Allow length of the light direction vector to influence strength of the light source.
This fixes the issue with objects and terrain being darker than they should be. As it turns out, most levels have not normalized light direction which happens to make light brighter and this is the expected result. To keep in line with GL14 engine, newer engines should use the length of the vector to make light brighter.
2020-07-31 22:01:33 +02:00
Fiftytwo 2023756023 Fix factory() being able to produce non-bot units 2020-07-30 11:11:51 +02:00
Fiftytwo a92fa950e2 Make Sniffers able to plant flags 2020-07-30 11:03:12 +02:00
Fiftytwo e63afb3461 Add WayPoint animation in deletemark 2020-07-30 04:21:35 +02:00
Fiftytwo 25a8d7b5b5 Move flatground scan button from Sniffers to Builders 2020-07-30 03:48:31 +02:00
Fiftytwo 4780716c18 Update translation files 2020-07-30 03:27:39 +02:00
MrSimbax 9cb80daedf Improve sound reloading
Also some minor refactoring.

Since realoding may take a lot of time, modman no longer reloads
the whole app on entering/leaving the screen.
2020-07-27 15:59:33 +02:00
Mateusz Przybył aa8122f16f
Merge pull request #1339 from immibis/fix-quicksave-sim-speed-crash
Fix crash when quick-saving with increased game speed
2020-07-26 15:17:17 +02:00
immibis 9e743e86af Fix crash when quick-saving with increased game speed 2020-07-26 14:55:56 +02:00
MrSimbax fd36ff3840 Fix crash when changing text with UTF-8 chars
The code left a byte from the previous text in CEdit UI control if
the new text is shorter than the old one. So an exception was thrown
because it's an invalid UTF-8 byte.
2020-07-25 21:20:19 +02:00
immibis 5eebe300fc
Support new-format text models through the same code path as old models; update Blender script (#1290) 2020-07-25 21:13:26 +02:00
MrSimbax 93f3abee1a Change mod version separator to dot
I don't know why I put comma in there and how I didn't notice this
earlier.
2020-07-24 12:57:45 +02:00
Mateusz Przybył fbe2191800
Allow producing objects with no keyword in CBOT (#1335) 2020-07-24 02:20:06 +02:00
MrSimbax b685d0060c Merge branch 'dev' into dev-mod-manager 2020-07-23 18:19:42 +02:00
MrSimbax 253cca379b List which level subdirectory a mod changes 2020-07-23 18:07:02 +02:00
MrSimbax e6ce4112c6 Update translations 2020-07-23 17:57:25 +02:00
MrSimbax 51668c12d7 Add changes listing to mods
It's just listing directories of a mod for now, but should give some
idea what the mod changes.

Also moved some functionality from pathman to modman.

Mods added with the `-mod` parameter are now managed by modman.
2020-07-23 17:44:38 +02:00
MrSimbax 16795e0d49 Use level parser instead of JSON for manifest 2020-07-22 21:40:13 +02:00
MrSimbax 62b770f7d3 Improve UI of mod manager a little
The arrow buttons are smaller and the up button is now above the down
button. What is more, the width of the back button is now the same as
in other places.
2020-07-22 17:50:19 +02:00
MrSimbax df415880d0 Fix linter issues 2020-07-22 17:26:46 +02:00
MrSimbax 1be69a0a51 Fix compile errors 2020-07-22 17:24:07 +02:00
MrSimbax 2b96eda86d Fix minor issues 2020-07-22 17:13:52 +02:00
MrSimbax f57da76ae8 Add handling of mods manifests
Also add Polish translations for mod manager related strings.
2020-07-22 16:35:47 +02:00
Mateusz Przybył a5c7187017
Fix crashes on SatCom in Moon missions (#1334) 2020-07-22 00:37:37 +02:00
MrSimbax 5112bf86df Fix linter issues 2020-07-21 21:11:08 +02:00
Mateusz Przybył 2d32e3a798
Merge pull request #1255 from timgott/smooth_shadows_gl21
Smooth shadows in gl21
2020-07-21 20:55:47 +02:00
Mateusz Przybył fd2b72b296
Merge pull request #1263 from nextghost/dev
Fix OpenGL specular lighting
2020-07-21 20:55:21 +02:00
MrSimbax eac74c23ec Fix linter issues 2020-07-21 20:39:00 +02:00
MrSimbax 242477e3ee Major UI change to mod manager
Move the button to the sidebar.

Add reordering option.

General improvements and refactoring.
2020-07-21 20:27:24 +02:00
Droog71 c4385961c4
Fix for issue #1163 (#1332)
* Clamped power variable before assignment to params in object manager. Attempted to fix formatting issues.

* Fixed Clamp function not implemented correctly.

* Fixed formatting issue, space after commas.

* Created ClampPower method in object_manager.h and implemented in object_manager.cpp, Removed similar code from robotmain.cpp

* Removed redundant call to ClampPower in object_manager.cpp

* Added second call to ClampPower back to object_manager.cpp. Made ClampPower method private. Attempted to fix whitespace issues.

* Fixed missing assignment to params.power in CreateObject method of object_manager.cpp

* fixed white space at end of line 182 in object_manager.h

* Fixed doxygen compatibility issue.
2020-07-20 21:55:44 +02:00
krzys_h f1d6787b08
Merge pull request #1333 from colobot/dev-gh-actions
Use colobot-lint from GitHub Actions rather than Jenkins and fix linter on PRs from forks
2020-07-20 21:42:13 +02:00
krzys-h b47ee4dd1e Don't try to upload annotations for pull requests from forks
The GITHUB_TOKEN is readonly when running from a fork... and I've found exactly 0 workarounds for this issue

I wanted to check permissions on the actual token rather than if we are running inside a fork, but the header that is supposed to specify the permissions doesn't exist under GH Actions (╯°□°)╯︵ ┻━┻
2020-07-20 21:06:13 +02:00
krzys_h dc6cfbb691 Use colobot-lint from GitHub Actions rather than Jenkins 2020-07-20 19:51:50 +02:00
Fiftytwo 754dfefefd Add Missions+ gamemode 2020-07-20 18:35:31 +02:00
MrSimbax 7e6782a1be Try to improve font reloading 2020-07-19 16:07:27 +02:00
MrSimbax 56a8c5eb48 Fix build error on GCC 2020-07-19 15:16:39 +02:00
MrSimbax 63bf6bed08 Add saving mods list in colobot.ini 2020-07-19 15:02:35 +02:00
Droog71 d64d78acfc
Fix for issue #1221 (#1230)
* Fix for issue #1221

* Removed object array and implemented GetObjectName method in it's place.

* Fixed indentation issue.

* Fixed white space at end of lines 1571, 1572.
2020-07-19 10:55:55 +02:00
MrSimbax 69d2d39c36 Add ability to use arrays in colobot.ini 2020-07-18 18:06:14 +02:00
MrSimbax a0635ae400 Fix linter issues 2020-07-18 15:01:36 +02:00
MrSimbax dc64b95406 Fix build error 2020-07-18 14:47:18 +02:00
MrSimbax 8390d85e46 Refactor the mod manager
Moved list of mods logic to a new CModManager class.

The list of enabled mods is now managed by a flag instead of directory
names of mods.

Mods are now disabled by default.

Also general cleanup, fixing issues from the code review in
https://github.com/colobot/colobot/pull/1191 and fixing linter issues.

Regression: the state of enabled/disabled mods is now not persistent.
The plan is to use some kind of config file for this.
2020-07-18 14:30:50 +02:00
Fiftytwo 95cab790c1 Rename 'freemissions' back to 'free' 2020-07-17 19:33:53 +02:00
Fiftytwo b72bedaf60 Add BrownMushroom and GreenMushroom categories in CBOT 2020-07-17 18:00:36 +02:00
MrSimbax 5f76722ecb Add error dialogs for open path/url buttons 2020-07-17 17:27:09 +02:00
MrSimbax 4905abe30b Merge branch 'dev-mod-manager' of https://github.com/DavivaD/colobot into dev-mod-manager 2020-07-17 11:49:51 +02:00
Fiftytwo ac32e40003 Add Ruin, Bush, GraviPlant, and Crystal categories in CBOT 2020-07-17 03:37:13 +02:00
Mateusz Przybył 52ed8041f7
Merge pull request #1330 from colobot/dev-cmake-targets
Use CMake targets instead of variables
2020-07-15 11:32:33 +02:00
Emxx52 0a3cdd342b
Merge pull request #1322 from colobot/dev-update-translations
Update translations
2020-07-14 23:52:20 +02:00
Emxx52 d29570c20a
Merge pull request #1331 from colobot/dev-heavyduty
Update Heavy bots, fix collisions
2020-07-14 22:52:08 +02:00
Mateusz Przybył 174669ec92
Merge pull request #1257 from immibis/1164-fix
When game speed is 2 or higher, run multiple ticks.
2020-07-14 22:41:05 +02:00
MrSimbax f87ae45745 Update translations
Also add a Polish translation for "Mute sounds in background".
Related issue: #1316
2020-07-14 22:16:56 +02:00
MrSimbax 2fa706a123 Add x86 MSVC build to GH Actions 2020-07-14 21:43:34 +02:00
MrSimbax 73429315a7 Add USE_STATIC_RUNTIME option
Mainly useful for MSVC.
2020-07-14 20:43:42 +02:00
MrJohn10 61126af370
Update contact section in Readme - add Discord server, remove forum and IRC channels (#1328) 2020-07-14 18:32:51 +02:00
MrSimbax 419bd1cc21 Fix CBOT stack overflow test failing on MSVC
Increased the stack size to the default (?) stack size on Linux.

The failing test name: CBotUT.FunctionRecursionStackOverflow
2020-07-14 14:26:37 +02:00
MrSimbax 167dd01bbe Revert "Fix CBotUT.FunctionRecursionStackOverflow test"
This reverts commit 004c861ba9.
2020-07-14 13:54:32 +02:00
MrSimbax df7cdd4b8e Fix some minor issues after CR 2020-07-14 13:51:07 +02:00
MrSimbax 2143f21828 Fix linter 2020-07-14 13:43:33 +02:00
MrSimbax 17e38bf66c Install PDB file if available 2020-07-13 23:39:11 +02:00
MrSimbax 3ec39047e1 Fix MXE build 2020-07-13 22:46:32 +02:00
MrSimbax a9717206f3 Try to fix linter errors 2020-07-13 22:04:33 +02:00
MrSimbax 634efbcabd Fix GLEW_STATIC redefinition warnings 2020-07-13 21:33:36 +02:00
MrSimbax c15efbad7b Revert "Delete FindGLEW"
This reverts commit 86f595b8ef.
2020-07-13 21:27:56 +02:00
MrSimbax f0ba8ec325 Revert "Fix warnings about redefining GLEW_STATIC"
This reverts commit 9cf30fd9bc.
2020-07-13 21:27:31 +02:00
MrSimbax fde66a9422 Make MSVC Windows build a separate job
Bring back the old file for Linux (with MXE).

Find number of logical processors on Windows by using PowerShell magic.
2020-07-13 21:19:03 +02:00
MrSimbax 17ece36b3e Enable OpenAL in CI MSVC build
The issue with OpenAL not compiling with vcpkg was solved upstream.
2020-07-13 20:43:32 +02:00
Fiftytwo 83a32b36b3 Fix collision persistence of exploding Heavy bots 2020-07-13 20:27:40 +02:00
Fiftytwo c80a816808 Merge branch 'dev' into dev-heavyduty 2020-07-13 19:51:23 +02:00
Fiftytwo a2c62a9da6 Make Heavy bots destroy bushes on contact 2020-07-13 19:44:50 +02:00
MrSimbax 86f595b8ef Delete FindGLEW 2020-07-12 23:18:21 +02:00
MrSimbax cc4cfd2122 Fix linter 2020-07-12 23:18:21 +02:00
MrSimbax c4037a885f Make CI Windows build with MSVC instead of MXE 2020-07-12 23:17:42 +02:00
immibis a2aeef0155 When game speed is 2 or higher, run multiple ticks. 2020-07-11 21:20:55 +02:00
MrSimbax fa5cf01af0 Mark libraries includes as system includes 2020-07-11 17:21:44 +02:00
MrSimbax 1b9d40d2fb Set C++ standard the modern CMake way 2020-07-11 17:20:41 +02:00
MrSimbax 9e8ebe4595 Checkout Google Test in GH workflow
I hope this works.
2020-07-11 12:41:33 +02:00
MrSimbax e8f9c0292b Handle the case where GTest is not found 2020-07-11 12:26:35 +02:00
MrSimbax 004c861ba9 Fix CBotUT.FunctionRecursionStackOverflow test
On MSVC it throws StackOverflow exception. I reduced the stack size to
make the test pass.
2020-07-11 12:17:20 +02:00
MrSimbax 81ddda4515 Make tests work with targets 2020-07-11 12:16:20 +02:00
MrSimbax 3da26a38ed Replace Google Test with a submodule 2020-07-11 10:54:52 +02:00
MrSimbax 6c3012b8a1 Fix hippomocks target
.h file shouldn't be listed as source to add_library(... INTERFACE)
2020-07-11 10:53:13 +02:00
Mateusz Przybył 90af1d9c16
Merge pull request #1318 from Erihel/mute_fix
Save audio settings when option changes
2020-07-10 20:30:41 +02:00
Krzysztof Dermont 7d7a29117e Save audio settings when option changes
Mute/unmute option when game windowis in background relies on settings
being updates. This happens when users leaves Options screen. This
commit adds saving audio settings on each change.

This is a fix for #1315
2020-07-10 20:15:18 +02:00
MrSimbax 9cf30fd9bc Fix warnings about redefining GLEW_STATIC
I guess this flag is now set by CMake somehow so we no longer need
to define it ourselves.
2020-07-10 18:55:47 +02:00
MrSimbax df65862c49 Start using CMake targets instead of variables
Moved most of the variables to targets in the main src.

Made libraries in repo export targets.

Refactor STATIC flags a little and add more.

This commit definitely breaks a lot of things like tests
but the main game builds at least with MSVC.
2020-07-10 18:49:54 +02:00
MrSimbax f2d91cde80 Update Find*.cmake modules
Make them export targets instead of variables.

Some platforms need libintl, abstract it to a Find*.cmake module.

Static linking requires linking to dependencies of dependencies (it is
as horrific as it sounds). This commit handles this only for libsndfile.

SDL2_image and SDL2_ttf probably also have some hidden dependencies.

FindGLEW module is now bundled with CMake, hence it is deleted.

Added Copyright.txt since some modules are taken from CMake.
2020-07-10 18:38:06 +02:00
MrJohn10 db031c7985 Merge branch 'vscode-instructions' of https://github.com/MrJohn10/colobot into vscode-instructions 2020-07-10 15:49:37 +02:00
MrJohn10 a3ceecb21e improve screenshots 2020-07-10 15:48:52 +02:00
MrJohn10 da6c0c66d7
delete dubled file 2020-07-10 15:26:20 +02:00
MrJohn10 767f7f0049 fix discord link 2020-07-10 15:24:19 +02:00
MrJohn10 85f0f88c20 overall improvements 2020-07-10 15:17:34 +02:00
MrJohn10 870d5237bb fixes, add screenshot 2020-07-10 13:18:57 +02:00
MrSimbax 4ae0360640 Remove source grouping temporarily
It's probably not how it should be done with modern CMake, so I'm
removing this for now to focus on other changes first.
2020-07-10 13:03:23 +02:00
Mateusz Przybył b8523aa1db
Merge pull request #1329 from colobot/dev-msvc-sed-fix
Fix update-pot not working with MSBuild
2020-07-10 11:33:41 +02:00
MrSimbax bf1982f4e4 Change `make update-pot` comment to cmake command
`make update-pot` only works if a generator producing Makefiles was
used with `cmake`. The `cmake` command to build a specific target
will work for any generator.
2020-07-10 11:01:47 +02:00
MrSimbax 963cd1b347 Fix sed cmd not working with MSBuild
Fixes the `'\1' is not recognized as an internal or external command`
error when trying to run the target `update-pot` with MSBuild.

The `|` characters probably messed with cmd.exe or PowerShell syntax
rules so they were replaced with slashes `/`.

Also, at least some implementations of sed for Windows would produce
CRLF line endings instead of LF line endings. The issue is fixed by
adding the flag `-b`.
2020-07-10 10:53:38 +02:00
Mateusz Przybył 4c02fe9cda
Merge pull request #1323 from colobot/dev-cmake-version-bump
Bump CMake version
2020-07-09 21:47:31 +02:00
MrJohn10 70b7a63b66 fix 2020-07-09 21:32:27 +02:00
MrJohn10 31781f214c fixes 2020-07-09 21:29:31 +02:00
MrJohn10 1b74cc1144 improve link 2020-07-09 21:27:33 +02:00
MrJohn10 535696de28 refactor 2020-07-09 21:25:48 +02:00
MrSimbax b9297cd9f4 Bump CMake version 2020-07-09 21:25:47 +02:00
MrJohn10 a78cc159f8 add cloning instructions, improve links 2020-07-09 21:25:19 +02:00
MrJohn10 fbb45807f1 Create intructions for using vscode 2020-07-09 21:16:03 +02:00
krzys_h 1c8c01ad96
Merge pull request #1325 from colobot/dev-gh-actions-lint
Send colobot-lint results to GitHub using annotations
2020-07-09 20:14:05 +02:00
MrSimbax 97b266182b Fix MXE build 2020-07-09 19:55:11 +02:00
krzys-h 4eaa8588d7 Add missing apt-get update 2020-07-09 19:37:52 +02:00
krzys-h 76bb08779a Switch to actions/checkout@v2
As per GitHub recommendations
2020-07-09 19:37:22 +02:00
krzys-h 03c60202b8 Clean up some of the old colobot-lint run scripts 2020-07-09 19:09:38 +02:00
krzys-h dcd84523ab Send colobot-lint results to GitHub using annotations
This makes the results visible directly in the pull request UI changes
view
2020-07-09 19:09:38 +02:00
Fiftytwo 6a23e97533 Fix collisions of animated plants 2020-07-08 14:17:08 +02:00
MrSimbax 4bd6e01b65 Fix filename style of the particles generator 2020-07-07 21:30:21 +02:00
MrJohn10 35b22f7a7f
Refactor - Move UI mouse particles generation to a new class. (#1308)
* Move UI mouse particles generation to a new class.

* refactoring

* refactor - change variable name

* change backslashes to forward slashes in include directives

* remove & from variable

* Refactoring - fix linter issues

* Refactoring - fix linter issues

* refactoring - fix linter issues
2020-07-07 20:48:52 +02:00
krzys_h 6efc977286
Merge pull request #1320 from colobot/dev-gh-actions
Set up GitHub actions
2020-07-07 19:35:19 +02:00
krzys-h a6a7b0c96c Display correct PR target branch as success rather than skipped 2020-07-07 18:37:21 +02:00
krzys-h 0ef21bfdbb Test builds on Ubuntu 16.04, 18.04 and 20.04
It's free, so why not?

This also partially deprecates the Docker container used for building -
now it's used only for MXE builds (because building MXE takes way too
long to do it inside the action)
2020-07-07 18:17:24 +02:00
krzys-h 6d7aadf987 Migrate to GitHub Actions
This is pretty much a straight port of our Jenkinsfile to GitHub
Actions. It could use some modernization in a few places, but it should
work for now.

Note that I left the Jenkinsfile for now - we'll be using them both
until we are sure that the GitHub Actions version is stable.
2020-07-07 18:09:12 +02:00
tomangelo 37e4ed8029
Updated license headers (#1317)
* Updated headers

* Updated more headers
2020-07-07 10:19:36 +02:00
Fiftytwo c50b36118e Revert "Make Recycler Recycle small Building Ruins." 2020-07-07 09:40:47 +02:00
MrSimbax 47687931d7 Fix compilation error
Apparently binary constants are a C++14 feature.
2020-07-06 18:29:30 +02:00
MrSimbax cb364a4f96 Fix typo 2020-07-06 18:29:30 +02:00
MrSimbax 06921e711d Fix 'uninitialized field' warnings 2020-07-06 18:29:30 +02:00
MrSimbax 124467c6e1 Fix 'naked new' warning 2020-07-06 18:29:30 +02:00
MrSimbax faa4a6eefa Fix "inconsistent declaration parameter name" 2020-07-06 18:29:30 +02:00
MrSimbax e96e8b46b2 Fix include style warnings 2020-07-06 18:29:30 +02:00
MrSimbax 6a22b709d6 Fix license headers 2020-07-06 18:29:30 +02:00
MrSimbax 7449111a00 Fix linter errors
"comparison of constant 240 with expression of type 'const char' is
always false"
also a whitespace issue

Changed the inequalities to bitwise comparisons, which hopefully don't
care about the sign.

I was considering just casting `c` to `unsigned char` but I doubt
it would be safe and multiplatform.
2020-07-06 18:29:30 +02:00
MrSimbax 6c715ffef9 Ignore all build* folders and the out folder 2020-07-06 18:29:30 +02:00
Krzysztof Dermont a65776e0e7 Prevent game crash on bad savegame title
It was noted in issues #1207 and #1232 that game can crash when savegame
does not contain title. This might be a problem when saving game fails
and user is informed about it only in console. Proper fix should be a
visible error message informing that saving failed. This commit filters
invalid savegames from load windows and prevents game crash in narrow
cases.
2020-07-06 11:38:23 +02:00
Krzysztof Dermont c04b2738de Clear screenshot if no save selected 2020-07-06 11:36:10 +02:00
Krzysztof Dermont 86dff7396e Disable Delete/Load buttons if no save selected 2020-07-06 11:36:10 +02:00
Krzysztof Dermont 1cffbb2bd3 Fix closing Load Save dialog without game selected
Pressing Load when no savegame is selected resumes game but Load Save window stays open.
2020-07-06 11:36:10 +02:00
melex750 55c0c3221d Add missing const keyword in CBotClass.cpp 2020-07-06 11:32:15 +02:00
melex750 1b93963413 Apply suggestions from code review
Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com>
2020-07-06 11:32:15 +02:00
melex750 a46fee4d4e Don't reset timer in CBotStack::AllocateStack
The timer is already reset in CBotProgram::Run.
This prevents many cases where the game will hang or rendering is interrupted.
This fixes behavior of the script example in #874.
The script example in #971 doesn't hang the game anymore.
2020-07-06 11:32:15 +02:00
melex750 a5909ac4de Add private and protected keywords for methods
fixes #854
fixes #882
2020-07-06 11:32:15 +02:00
melex750 4a62e9ed76 Separate searching for functions and methods
fixes #207
fixes #1016
2020-07-06 11:32:15 +02:00
Emxx52 0102e45855
Merge pull request #1049 from colobot/dev-cbot-factory
Rework new functions so they follow established syntax rules
2020-07-05 17:26:04 +02:00
Fiftytwo 736c0894d1 Update data submodule 2020-07-05 15:44:43 +02:00
Krzysztof Dermont 04b1944939 Add option to mute sounds when game is not focused
Closes #823
2020-07-05 14:58:46 +02:00
melex750 e108715760 Document public member functions for CFileDialog 2020-07-05 14:33:59 +02:00
melex750 3566fb4826 Add 'select folder' mode for file dialog 2020-07-05 14:33:59 +02:00
melex750 a3dbeb9829 Play a sound when open/save fails 2020-07-05 14:33:59 +02:00
melex750 50b2afbda8 Renaming variables and other minor fixes 2020-07-05 14:33:59 +02:00
melex750 5cc565439c Move open/save dialog from CStudio to CFileDialog 2020-07-05 14:33:59 +02:00
suve e2eb5b91e0 Throw an exception on invalid input in StringUtils::Utf8CharSizeAt() 2020-07-05 13:57:39 +02:00
suve 86ef158c00 Detect invalid values in StringUtils::Utf8CharSizeAt() 2020-07-05 13:57:39 +02:00
melex750 ebcb124b0e Fix failed assert when parameter not initialized
fixes #1296
2020-07-05 13:03:56 +02:00
tomangelo2 dece19fbec Style fix 2020-07-05 12:58:45 +02:00
tomangelo2 a2df003b7e Fix radar function parameter type detection, fixes #1298 2020-07-05 12:58:45 +02:00
melex750 fb9fa49ce8 Use PHYSFS for saving screenshots 2020-07-05 12:55:40 +02:00
Droog71 f449d9c800 Fix for issue #842 2020-07-05 11:04:21 +02:00
Fiftytwo a7d4eb00b6 Update po files 2020-06-21 22:00:09 +02:00
Fiftytwo 55b46942cb Remove unnecessary whitespaces 2020-06-16 21:02:52 +02:00
Fiftytwo 5c0cfba8ae Merge branch 'dev' into dev-cbot-factory 2020-06-16 20:07:03 +02:00
Emxx52 6a0234edd5
Merge pull request #1050 from colobot/dev-builders
Implement Builders
2020-06-16 19:32:58 +02:00
Fiftytwo 6d584ba481 Update data submodule 2020-06-16 18:54:35 +02:00
Fiftytwo 373d8de7d0 Make burning and destroyed objects physical 2020-06-13 16:08:06 +02:00
Fiftytwo 7f9efea0a2 Remove unnecessary whitespaces 2020-05-15 20:29:48 +02:00
Fiftytwo bbf9356628 Fix colobot-lint error 2020-05-15 19:26:03 +02:00
Fiftytwo 0b9673029d Merge dev into dev-builders and resolve conflicts 2020-05-15 15:06:37 +02:00
Fiftytwo 9a14c8c7e9 Merge branch 'dev' of https://github.com/colobot/colobot into dev 2020-05-15 01:08:06 +02:00
Emxx52 354bbf9287
Merge pull request #1058 from colobot/dev-targetpractice
Update Trainer (Practice) bots, trainer=1 objects, and TargetBot
2020-05-14 23:32:32 +02:00
Fiftytwo 7bd18f9c8e Update colobot.pot 2020-05-14 15:46:45 +02:00
Fiftytwo 0f33dbe154 Add holder model for trainer Subber 2020-05-14 13:36:37 +02:00
Michał Górny f3ae4b4209 Fix missing <limits> include
Add missing <limits> include for std::numeric_limits.  This fixes
build failure after boost stopped implicitly including it for us.
2020-05-14 11:26:15 +02:00
Marcin Zajączkowski 11e67cc61b Add info about Fedora package to README 2020-05-06 18:58:51 +02:00
Emxx52 00d72d8d7b
Merge pull request #1265 from DavivaD/dev-thumper-patch
Thumper Patch
2020-04-24 21:09:04 +02:00
Fiftytwo d8e0465d6d Merge branch 'dev' of https://github.com/colobot/colobot into dev 2020-04-07 23:17:56 +02:00
Emxx52 92c9031749
Merge pull request #1295 from colobot/dev-fix-unstable-build
Fix Jenkins marking builds as unstable
2020-04-07 23:09:14 +02:00
MrSimbax 17ba464d33 Fix so called ''compilation errors'' in linter 2020-04-07 20:16:23 +02:00
MrSimbax ad33e0e624 Fix 'code block placement' linter issues 2020-04-07 20:05:32 +02:00
MrSimbax f09768fb2d Fix 'undefined function' linter issue 2020-04-07 19:13:30 +02:00
Fiftytwo 9db6bb63e4 Merge branch 'dev' of https://github.com/colobot/colobot into dev 2020-04-07 19:10:32 +02:00
MrSimbax 87fec23f4b Fix 'class naming' linter issues 2020-04-07 18:59:46 +02:00
Emxx52 5815db4062
Merge pull request #1247 from colobot/dev-basedir
Add support for binary relocation
2020-04-07 18:49:57 +02:00
MrSimbax b925838a91 Try no. 3 to fix Jenkins 2020-04-07 17:43:45 +02:00
Fiftytwo e5d994b9e2 Merge branch 'dev' of https://github.com/colobot/colobot into dev 2020-04-07 14:46:43 +02:00
Fiftytwo ddab760624 Add rollert.png to OldModelManager 2020-04-07 14:35:59 +02:00
Fiftytwo 0c69dc8d30 Make Ants and Spiders able to destroy TargetBot 2020-04-05 16:05:57 +02:00
MrSimbax c5e8df16e0 Try #2 to fix Jenkins build 2020-04-05 14:20:53 +02:00
MrSimbax 0597c0efda Try to fix Jenkins build 2020-04-05 14:11:08 +02:00
MrSimbax 621453a01c Make all relative paths use base dir 2020-04-05 13:24:45 +02:00
MrSimbax 3fbfadb0d4 Merge branch 'dev' into dev-basedir 2020-04-03 21:12:48 +02:00
MrSimbax 8f122d6603 Fix MSVC compilation (again) 2020-04-03 20:18:14 +02:00
MrSimbax d4b2f23c4a Add handling of env variables 2020-04-03 20:15:24 +02:00
MrSimbax ad02b55541 Merge branch 'dev-basedir' of github.com:colobot/colobot into dev-basedir 2020-04-03 15:03:04 +02:00
Fiftytwo b5466261d4 Make buildings inherit trainer param from builder 2020-03-31 19:02:53 +02:00
Fiftytwo 0d6218bfa0 Fix trainer Builder segfault 2020-03-31 16:57:45 +02:00
tomangelo 088c661839
Merge pull request #1291 from suve/fix-missing-includes
Add missing includes in CBotExprLitString.cpp
2020-02-09 16:06:25 +01:00
suve fc2bd68876 Fix missing std includes 2020-02-09 00:36:05 +01:00
Fiftytwo 853d8eee5d Adjust HeavyTrainer rear light sprite position 2020-01-11 18:39:44 +01:00
Fiftytwo 5bf6f12ae5 Add HeavyTrainer texture recoloring 2020-01-11 17:04:40 +01:00
tomangelo a67266553f
Merge pull request #1253 from melex750/dev-savegame
Add types byte, short, char, long, and double
2020-01-02 15:01:16 +01:00
tomangelo 51cde3c868
Merge branch 'dev' into dev-savegame 2020-01-02 15:00:33 +01:00
tomangelo b8c4232312
Merge pull request #1262 from B-CE/i18n-fr2
Update i18n fr
2020-01-02 14:42:15 +01:00
tomangelo2 f97da6482b Fixed escape character 2020-01-02 13:52:07 +01:00
tomangelo2 4e4c3671c6 Fixed Jenkins builds 2020-01-02 13:52:07 +01:00
tomangelo2 b9ac5688e9 Fix package name in compilation instruction 2020-01-02 13:51:01 +01:00
Martin Doucha 69aba7c352 Fix OpenGL 3.3 specular lighting 2019-12-29 14:46:39 +01:00
Martin Doucha 0d30624119 Fix OpenGL 2.1 specular lighting 2019-12-29 14:46:39 +01:00
tomangelo 1ca213df09
Merge pull request #1274 from mgorny/ninja-man-fix
Fix manpage build rules to work with Ninja generator
2019-12-29 00:10:42 +01:00
tomangelo 8648de9581
Merge pull request #1278 from pkubaj/patch-1
Fix build on ARM and PPC
2019-12-28 22:33:04 +01:00
tomangelo c9ec197d76
Merge pull request #1275 from suve/add-missing-Polish-strings
Add some missing strings to the Polish translation
2019-12-28 20:54:05 +01:00
tomangelo 587e189e97
Merge pull request #1250 from colobot/dev-compilation-fix
Fixes compilation problem
2019-12-28 20:52:36 +01:00
pkubaj 1a771b0e72
Fix build on ARM and PPC
ARM and PPC use unsigned char by default.
2019-10-18 14:00:37 +02:00
suve 68ddaf550b Add some missing strings to the Polish translation 2019-10-07 14:39:51 +02:00
Michał Górny 4f9d9d0609 Fix manpage build rules to work with Ninja generator
Specify outputs for po4a command explicitly rather than via implicit
target, in order to clearly establish the dependency chain between
manpages and input files generated by po4a.  This is necessary to make
it possible to use Ninja generator.  Otherwise, the implicit
dependencies cause the following error:

    ninja: error: '../desktop/lang/fr/colobot.pod', needed by 'desktop/fr/colobot.6', missing and no known rule to make it
2019-09-24 16:36:24 +02:00
MrSimbax 61a7aa2592 Fix minor memory leak 2019-08-07 09:51:27 +02:00
MrSimbax 2d3d03cc38 Use SDL_GetBasePath() instead of physfs because it's buggy in old version 2019-08-07 09:51:27 +02:00
MrSimbax 41379ded7e Use workdir paths on dev builds 2019-08-07 09:51:27 +02:00
MrSimbax 5cefa57dd5 Use base dir instead of working dir for data files 2019-08-07 09:51:27 +02:00
DavivaD 50c3c45ef8 Show only local mods on the list 2019-07-27 17:58:12 +02:00
DavivaD 6f3b14202e Mod Manager i18n 2019-07-27 17:03:33 +02:00
DavivaD 7d30a82747 Move platform-dependent code to system_*.cpp 2019-07-27 16:59:51 +02:00
DavivaD cd140f1384 Move mod loading/unloading stuff to a new class + fix some derps 2019-07-27 03:36:03 +02:00
DavivaD 190e04fdd7 Move PT_FRAGV to the end of the pyro_type.h list + Undo reordering 2019-07-26 17:33:04 +02:00
DavivaD 9c2ea5f488 Undo some changes + space fixes 2019-07-22 17:04:15 +02:00
DavivaD b8b2d32bc1 Thumper Patch 2019-07-22 01:15:11 +02:00
Fiftytwo 62620a93cd Make Wrecks destroyable; make TargetBot more fragile 2019-07-17 02:57:47 +02:00
Fiftytwo ed8dc04d94 Make TargetBot explode in water 2019-07-05 16:03:29 +02:00
B-CE 0517115557 Upd i18n fr : complete + uniformize
Bots
  Déménageur -> Préhenseur
  shooter    -> tireur
  phazer     -> hachoir
  ...

    Buildings
  Fabrique de robots  -> Usine de robots
  convertisseur       -> raffinerie
  borne d'information -> station relais
  ...

    Objects
  batterie (standard)
  pile nucléaire
  ...
2019-06-25 07:51:13 +02:00
B-CE 17d85eb434 Translate french comments + correct typo 2019-06-19 08:50:47 +02:00
melex750 17d0d2abb1
Fix compiling literal numbers 2019-05-12 08:33:53 -04:00
Tim Göttlicher e9a153df14 Smoother shadows on OpenGL 2.1 2019-04-28 01:27:12 +02:00
melex750 5f089f4a9b Fix and improve switch...case (#1008) 2019-04-11 05:34:00 -04:00
melex750 1058a326ad Add binary and character literals in CBOT 2019-04-11 05:14:11 -04:00
melex750 bc572aa52f Add sizeof() operator for numeric data types 2019-04-11 04:21:22 -04:00
melex750 c0cdd84e85 Add missing primitive data types in CBOT 2019-04-11 04:19:29 -04:00
melex750 250ea57e8b Fix arithmetic operations with integers (#993)
Also fixed unsigned right shift operator ">>>"
2019-04-11 04:15:27 -04:00
melex750 a66b3d0672 Refactor SaveState and RestoreState to use streams 2019-04-11 04:13:13 -04:00
tomangelo 97a8cfe6f9
Merge pull request #1251 from fernape/fix-freebsd-build
Add FreeBSD support.
2019-04-10 22:13:15 +02:00
fernape 44083053ce Add FreeBSD support.
Add a new PLATFORM_FREEBSD variable. We can compile like MacOS with just an
extra linker flag.
2019-03-09 19:04:00 +01:00
Tomasz Kapuściński 16a1dc7b9d Removed unnecessary dependency on libwebp which causes compilation problems with static builds. 2019-03-04 21:40:59 +01:00
MrSimbax d038d18943 Add trailing ; to Keywords entry in colobot.desktop
Related issue: #1246
2019-02-26 17:41:51 +01:00
MrSimbax 472aadf9ab Fix minor memory leak 2019-02-25 23:42:34 +01:00
MrSimbax 266944c9d2 Use SDL_GetBasePath() instead of physfs because it's buggy in old version 2019-02-25 23:00:05 +01:00
MrSimbax 7268bcca11 Use workdir paths on dev builds 2019-02-24 17:16:54 +01:00
MrSimbax edeae704f9 Use base dir instead of working dir for data files 2019-02-24 15:49:05 +01:00
MrSimbax d4ab82eaae Release 0.1.12-alpha: Bump version 2019-02-23 20:01:33 +01:00
MrSimbax ef6b692d41 Post-release 0.1.12-alpha 2019-02-23 20:01:33 +01:00
MrSimbax 6ec644d20b Release 0.1.12-alpha: Merge branch 'dev' 2019-02-23 20:01:33 +01:00
MrSimbax 7d99aa954b Fix release.py 2019-02-23 20:01:21 +01:00
MrSimbax 46098834a1 Update data submodule 2019-02-23 18:54:39 +01:00
MrSimbax aca552242f Update po files 2019-02-23 18:51:37 +01:00
tomangelo 0efb8d50ba
Merge pull request #1244 from colobot/dev-portable-saves
Fix PORTABLE_SAVES flag not working
2019-02-23 18:28:06 +01:00
MrSimbax 0eb31a1f45 Fix PORTABLE_SAVES flag not working 2019-02-23 13:12:37 +01:00
Mateusz Przybył 275724ab97
Build AppImage in Jenkins (#1243) 2019-02-21 17:46:11 +01:00
krzys_h e02a3373fd
Update Jenkinsfile for dockerized build environment (#1240) 2019-02-18 19:18:53 +01:00
tomangelo2 a46750ede2 Fix crash when destroying unpowered PowerPlant with Titanium
Appendix to pull #1206
2019-02-18 14:43:56 +01:00
tomangelo2 0f6e1d7d4a Style fix 2019-02-18 14:43:56 +01:00
tomangelo 0da792c77c
Merge pull request #1205 from ananace/add-appdata
Add an appdata XML for Linux packaging (#1204)
2019-02-09 21:42:05 +01:00
tomangelo 9fe05f4472
Merge pull request #1237 from Uposax/master
Complete french translation
2019-02-07 01:37:43 +01:00
tomangelo bc3fbd21d0
Merge pull request #1231 from colobot/dev-issue-1128
Potential fix for issue #1128
2019-02-07 01:12:10 +01:00
tomangelo b50a71bde4
Merge pull request #1239 from suve/use-sizeof-in-ModelOutput-WriteOldModel
Tweak strncpy() usage in ModelOutput::WriteOldModel
2019-02-07 01:11:55 +01:00
suve 086e07168d Use sizeof() instead of magic number for strncpy in ModelOutput::WriteOldModel 2019-02-02 18:53:36 +01:00
tomangelo 02fd258697
Merge pull request #1206 from iceslab/dev
Fixes for #1203 and #1194
2019-01-29 20:31:57 +01:00
tomangelo 04b8bf6c42
Merge pull request #1235 from vkuzkokov/master
Put pitch and roll in [-180,180) range.
2019-01-29 20:31:37 +01:00
maf-ia 2175e7f90a Merge branch 'master' of https://github.com/Uposax/colobot 2019-01-12 21:44:00 +01:00
krzys-h 4c3440bbe6 Fix building of colobot.rc on Windows 2019-01-12 21:43:01 +01:00
maf-ia 634248885f Complete last 5 french sentences not fully translated 2019-01-12 21:35:51 +01:00
maf-ia 63bf8e07da Complete last 5 french sentences not fully translated 2019-01-12 21:28:49 +01:00
Vladislav Kuzkokov e3f53dc203 Put pitch and roll in [-180,180) range.
Reasonable values lie close to either side of 0.
2019-01-06 07:09:57 +01:00
tomangelo2 be97167994 Potential fix for issue #1128 2019-01-02 01:18:45 +01:00
tomangelo2 92d2de5325 Fixed VSync options list
Now VSync list is aligned for same height as resolution list from the bottom, as it's very hard to align them from top on different screen resolutions.
2019-01-02 00:34:34 +01:00
tomangelo 9cf89db8af
Merge pull request #1213 from ananace/fix-xdg
Fix Linux savegame path issue, closes #1212
2018-12-23 16:43:59 +01:00
Fiftytwo 723c552783 Add Heavy and Amphibious trainer bots 2018-12-23 07:04:06 +01:00
Mateusz Przybył d57c45cbb2
Merge pull request #1211 from suve/limit-game-speeds
Add a minimum & maximum game speed limit
2018-12-22 15:49:53 +01:00
Mateusz Przybył 3db153f964
Merge pull request #1202 from colobot/dev-restext
Add a note mentioned in issue #1197
2018-12-22 15:17:28 +01:00
suve 508e7529d2 Use Math::Clamp() when limiting game speed 2018-11-27 19:25:56 +01:00
Alexander Olofsson d11404a6e9
Fix Linux savegame path issue, closes #1212 2018-11-25 14:49:01 +01:00
suve 4305f8de03 Add a minimum & maximum game speed limit 2018-11-18 21:09:11 +01:00
Alexander "Ananace" Olofsson 634d087d5e
Don't grab the AppData XML from binary dir
Only supposed to grab from there when generating the file from CMake variables.
2018-10-29 18:32:34 +01:00
Bartosz Cieśla 7c88a6e667 Fix for #1194 2018-10-13 10:12:41 +02:00
Bartosz Cieśla abf1a60a86 Fix for #1203 2018-10-10 19:14:23 +02:00
Alexander Olofsson 0dbf82ca4e Add the donation link to the appdata XML as well 2018-10-04 01:07:20 +02:00
Alexander Olofsson 2871bac0ce Add an appdata XML for Linux packaging
Fixes #1204
2018-10-04 00:52:31 +02:00
tomangelo 9165a8475e
Merge pull request #1201 from nextghost/dev
Minor improvements in Czech translation
2018-09-08 22:03:46 +02:00
tomangelo 3f6e84b418
Merge pull request #1167 from badernageral/dev
Translation to Brazilian Portuguese
2018-09-08 22:03:28 +02:00
tomangelo 9aa3773752
Merge pull request #1199 from CHmSID/fix-more-warnings
Fix another GCC 8.2.0 warning
2018-09-08 22:01:01 +02:00
tomangelo a76bbe49ed
Merge pull request #1189 from colobot/dev-msvc
Add some Visual Studio specific fixes
2018-09-08 22:00:47 +02:00
tomangelo aed74321cb
Merge pull request #1115 from B-CE/dev-tabMgt
fix #274 : pasting tabs
2018-09-08 22:00:18 +02:00
tomangelo2 b37cf36a52 Updated pot files
Just figured out I didn't updated them before
2018-08-21 21:35:37 +02:00
tomangelo2 ee0b46a278 Add a note mentioned in issue #1197 2018-08-21 21:28:45 +02:00
tomangelo 31b309fa24
Merge pull request #1186 from colobot/dev-switch-case
Fix switch case documentation shortcut
2018-08-21 12:16:41 +02:00
tomangelo 7d46ee762a
Merge pull request #1181 from colobot/dev-vsync
Add VSync switch to Device tab
2018-08-21 12:16:03 +02:00
Martin Doucha 47ff155022 Minor improvements in Czech translation 2018-08-20 23:05:19 +02:00
Jerzy B 6f0a294048 Give space for a null character in texture name 2018-08-18 09:11:46 +01:00
Jerzy B f3b30625ee Fix GCC 8 warning about sprintf overflow (#1192) 2018-08-12 07:49:45 +02:00
DavivaD e823c209fa Fix crash while loading mod and blank settings menu while paused game 2018-08-02 17:21:31 +02:00
DavivaD 1b47cf76d3 Implement Mod Manager 2018-08-02 07:38:32 +02:00
MrSimbax 7e19622b85 Allow both F11 and F12 for stats 2018-07-25 23:45:15 +02:00
MrSimbax cb701cacb8 Add a workaround for failed assertion in VS debugger
Assertion failed: ploc->_Mbcurmax == 1 || ploc->_Mbcurmax == 2

Apparently MS C/C++ library doesn't support UTF-8 locales, which causes the assertion to fail. My solution is to ignore the system locale and try to set the classic one.

LibreOffice seems to have this problem fixed in less simple way: https://gerrit.libreoffice.org/#/c/54110/
2018-07-25 21:44:31 +02:00
MrSimbax 32d3d1eb92 Change key for debug menu to F10 and for stats to F11
F12 is used by Visual Studio debugger to trigger a breakpoint and apparently it cannot be changed:

"The F12 key is reserved for use by the debugger at all times, so it should not be registered as a hot key. Even when you are not debugging an application, F12 is reserved in case a kernel-mode debugger or a just-in-time debugger is resident."
Source: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646309.aspx?f=255&MSPPError=-2147217396
2018-07-25 21:38:47 +02:00
MrSimbax f93fd61c26 Rename OFFICIAL_BUILD to OFFICIAL_COLOBOT_BUILD
In order to avoid conflict with OFFICIAL_BUILD variable inside ntverp.h. It caused compilation error "invalid integer expression"

https://github.com/tpn/winsdk-10/blob/master/Include/10.0.10240.0/shared/ntverp.h#L134
2018-07-25 21:34:39 +02:00
tomangelo 5080cb46b1
Merge pull request #1031 from tomangelo2/dev
Added fonts configurability by a separate file
2018-07-25 19:51:55 +02:00
tomangelo2 3383532752 Changed font_config to font_loader
Apparently linter doesn't like files with `config` in its name
2018-07-25 00:44:06 +02:00
tomangelo2 d84be03a83 Removed non-existing font from code
Forgot to check build on clean data directory
2018-07-23 14:10:27 +02:00
tomangelo2 df46bcfe2d Fix another linter warning 2018-07-23 14:03:59 +02:00
tomangelo2 14b6f7cafa Fixed some linter warnings in font_config files 2018-07-23 12:46:47 +02:00
tomangelo d90592f7b6
Merge pull request #1162 from AbigailBuccaneer/gl-cleanup
Clean up and improve CGLxxDevice code
2018-07-23 12:15:08 +02:00
tomangelo 5041aa377d
Merge pull request #1156 from AbigailBuccaneer/redundant-shadowmap-renderbuffer
Don't create a color renderbuffer for shadow map
2018-07-23 12:14:45 +02:00
tomangelo2 fb00898035 Fix switch case documentation shortcut
Also some polishing of loops help texts
2018-07-21 00:09:37 +02:00
Fiftytwo 3f04654cd3 Make ruins destroyable 2018-07-13 13:16:30 +02:00
Fiftytwo 5b2b632de3 Add TargetBot research; make it fully operational 2018-07-13 00:03:20 +02:00
Fiftytwo 5b2f3111b6 Add trainer=1 SpaceShip 2018-07-12 20:54:58 +02:00
Fiftytwo 146581e44c Add trainer=1 AutoLab 2018-07-12 20:35:50 +02:00
Fiftytwo 02eb4623b9 Add trainer=1 ResearchCenter 2018-07-12 20:17:09 +02:00
Fiftytwo d0e29d4875 Add trainer=1 BotFactory 2018-07-12 19:55:31 +02:00
tomangelo2 4bfada2ad6 Better handling of VSync errors 2018-07-05 21:18:14 +02:00
tomangelo2 608d59f07b Moved VSync setting from Experimental to Setup 2018-07-05 20:56:38 +02:00
tomangelo2 359abf9a82 Add VSync switch to Device tab 2018-07-05 19:43:56 +02:00
Mateusz Przybył abb7d54ef5 Add support for VS CMake/vcpkg compilation (#1174)
* Add support for VS CMake/vcpkg compilation

* Fix system_windows.cpp compilation

* Add optimization and hidden console to MSVC release builds
2018-06-04 09:17:51 +02:00
José Robson Mariano Alves 0c16d9a272 Translation to Brazilian Portuguese 2018-05-16 10:22:57 -03:00
krzys-h 073191d1ea Small CPathManager refactoring 2018-05-16 13:28:06 +02:00
krzys-h c218fcce98 Merge branch 'master' into dev 2018-05-16 11:55:15 +02:00
krzys-h 17447e813b Fix building of colobot.rc on Windows 2018-05-16 11:55:06 +02:00
José Robson Mariano Alves dbd1f601da Translation to Brazilian Portuguese 2018-05-15 18:31:41 -03:00
José Robson Mariano Alves be1066912f Translation to Brazilian Portuguese 2018-05-15 16:50:42 -03:00
José Robson Mariano Alves 2b933264fc Translation to Brazilian Portuguese 2018-05-15 16:07:03 -03:00
krzys-h cdb8a4871a Release 0.1.11.1-alpha: Bump version 2018-05-10 21:20:13 +02:00
krzys-h 12c969c71c Post-release 0.1.11.1-alpha 2018-05-10 21:20:13 +02:00
krzys-h af306c4790 Release 0.1.11.1-alpha: Merge branch 'dev' 2018-05-10 21:20:13 +02:00
krzys-h 7aaac449f5 Fix release script version override
This fixes a bug in 94a18e9648
2018-05-10 21:16:42 +02:00
krzys-h acc3362172 Update data submodule 2018-05-10 21:06:10 +02:00
krzys-h f538b4f477 What did I say about commiting in a hurry 2018-05-10 11:32:33 +02:00
krzys-h 12cf57409c Support more buttonX.png files in other places than just buttons 2018-05-10 11:24:59 +02:00
krzys-h 05bc65a90b Add support for more buttonsX.png textures (for modders) 2018-05-10 11:12:45 +02:00
krzys-h 8095dc14f7 Add support for custom button= for View cameras 2018-05-10 11:12:22 +02:00
krzys-h ed397d2b0f Make sure aliens hatched from eggs are not selectable by default, closes #1054 2018-05-09 23:25:52 +02:00
krzys-h 319d8e6854 Fix delete() not returning sometimes, closes #1067 2018-05-09 23:12:26 +02:00
AbigailBuccaneer e481905a25 Do less state setting in gl14 and gl21 2018-05-09 21:03:08 +01:00
AbigailBuccaneer c9a8a242a0 Remove CGL14Device's support for display lists
Closes #1153.
2018-05-09 21:03:08 +01:00
AbigailBuccaneer f8ebc6ec21 Remove code for drawing dynamic vertex formats
It's unused, and it's a bad idea - it's important for authoring tools
and for performance that vertex formats are well-defined instead of
dynamically created.
2018-05-09 21:03:08 +01:00
AbigailBuccaneer 94b30c00a0 Remove code duplication in CGLxxDevice 2018-05-09 21:03:08 +01:00
krzys-h 10fc47476b Fix code style 2018-05-09 18:34:27 +02:00
krzys-h 85772376fa Merge ScoreboardSortType with main Scoreboard command 2018-05-09 18:33:27 +02:00
krzys-h 1ed3f4b215 Add EndMissionTeams immediateWin=true; make the teams on win screen sorted 2018-05-09 18:28:25 +02:00
AbigailBuccaneer c027b54add Don't create a color renderbuffer for shadow map
When rendering the shadow map offscreen using framebuffer objects, it's
not necessary to create a color renderbuffer. Currently
FramebufferParams only lets you choose between a renderbuffer and a
texture for both color and depth attachments. This changes that, and now
you can ask for a texture, a renderbuffer, or nothing.

This improves performance. On my computer, with an 8192x8192 shadow map,
this improves overall frame time by 8.0%.
2018-05-09 17:25:52 +01:00
krzys-h abe489e294 Add EndMissionTimeout 2018-05-09 17:47:21 +02:00
krzys-h 94a18e9648 Add version override to release script
NOT TESTED!
2018-05-09 17:23:46 +02:00
krzys_h 761694fa05
Merge pull request #1161 from AbigailBuccaneer/fix/1160
Fix -Wsuggest-override compile errors in tests
2018-05-09 17:10:44 +02:00
AbigailBuccaneer 807d6e40e3 Fix -Wsuggest-override compile errors in tests
Fixes #1160
2018-05-09 08:49:23 +01:00
krzys-h a3def6d683 Disallow firendly fire in ScoreboardKillRule 2018-05-08 23:57:13 +02:00
krzys-h 0baf9f8077 Don't commit code in a hurry like that... 2018-05-08 23:47:50 +02:00
krzys-h f03c3dbc10 Implement ScoreboardObjectRule 2018-05-08 23:44:23 +02:00
krzys-h 05bdd74bef Update data submodule 2018-05-08 20:27:11 +02:00
krzys-h dd40c4d4ee Make magnifyDamage=0 for fragile objects actually work
This fixes a bug in 36d2cf14b8
2018-05-08 19:54:25 +02:00
krzys-h db72a36315 Fix code style 2018-05-08 19:44:24 +02:00
Fiftytwo caf58c8ab8 Merge branch 'dev' of https://github.com/colobot/colobot into dev 2018-05-07 21:48:48 +02:00
krzys_h 5283865a5c
Merge pull request #1136 from colobot/dev-cbot-optimizations
Some CBot code optimizations
2018-05-07 20:53:52 +02:00
krzys_h 182c4c5cbf
Merge pull request #1154 from AbigailBuccaneer/shadow-shimmering
Fix shadow shimmering
2018-05-07 20:53:28 +02:00
krzys_h a54f65f71b
Merge pull request #1152 from AbigailBuccaneer/consistent-shadow-antialiasing
Improve shadow quality and performance in gl33
2018-05-07 20:53:21 +02:00
krzys_h 50ed675acd
Merge pull request #1150 from AbigailBuccaneer/debug-rendering
Add generic debug rendering functions
2018-05-07 20:53:12 +02:00
krzys_h f146d2885b
Merge pull request #1149 from AbigailBuccaneer/tighter-visibility-checking
Improve object visibility culling with tighter bounding spheres
2018-05-07 20:53:00 +02:00
krzys_h 44f2684c70
Merge pull request #1148 from AbigailBuccaneer/text-batching
Improve text rendering performance
2018-05-07 20:52:50 +02:00
krzys-h 6e273e7e33 Declare CBotVar::m_token as const 2018-05-07 20:51:44 +02:00
krzys_h 05fe7431c4
Merge pull request #1143 from AbigailBuccaneer/fix/1087-positional-sounds
Fix global sounds being positioned at camera
2018-05-07 20:43:03 +02:00
krzys_h b36d40a509
Merge pull request #1151 from melex750/dev-savegame
Fix saving/loading "NewScript" programs for factory bots
2018-05-07 20:42:51 +02:00
krzys_h b9e2edce6c
Merge pull request #1146 from colobot/dev-scene-camera
Implement viewpoint feature
2018-05-07 20:42:18 +02:00
krzys_h 099a906b17
Merge pull request #1129 from colobot/dev-scoreboard-sort
Add realtime scoreboard sorting
2018-05-07 20:42:02 +02:00
krzys_h 35640b8e3f
Merge branch 'dev' into dev-scoreboard-sort 2018-05-07 20:41:40 +02:00
krzys-h 36d2cf14b8 Make magnifyDamage influence fragile objects 2018-05-07 20:31:36 +02:00
krzys-h 1d09ee9b3c Fix transportable object damage rules
This makes the rules match the original Colobot like they were supposed to
2018-05-07 20:31:36 +02:00
krzys-h 6ccf32ec68 fixup! Fix code style in #1150 2018-05-07 20:28:31 +02:00
AbigailBuccaneer abeb7fceb2 Fix shadow shimmering
Shadow shimmering is a visual artefact where the outlines of shadow
mapped objects don't stay stable when the camera is moved or rotated.
The reason is that as the shadow map's origin moves, the objects
rendered to the shadow map have temporal aliasing around their edges.

The solution is to only move the shadow map in texel-sized increments.
Because the shadow map's projection is orthographic, moving the shadow
map origin in texel increments ensures that objects that aren't moving
don't show any temporal aliasing, as the position of the samples of the
object in worldspace stay the same.
2018-05-04 10:56:37 +01:00
AbigailBuccaneer 0d6fffd91f Improve shadow quality and performance in gl33
If CONFIG_QUALITY_SHADOWS is defined (which it always is) then the
fragment shader code that samples the shadow map will take five samples
in a cross shape around the point to be sampled, to apply antialiasing.

Currently, the offset of these samples is hardcoded to 0.00025× the
shadow map resolution. This is very inconsistent: if the shadow map
resolution is 128×128, then these samples are 0.032 texels apart, which
is a waste of four texture samples, and essentially means that no
antialiasing is applied. If the shadow map resolution is 8192×8192, then
these samples are 2.048 texels apart, which causes visual artefacts
around shadow edges, instead of giving smoother shadows.

The correct thing to do is to always sample exactly one texel away from
the original position. This is easy in GLSL 3.30, as it includes a
textureOffset function which offsets a texture fetch by an exact number
of texels. This is faster than manually calculating an offset ourselves,
it fixes visual artefacts at high resolutions, and it properly applies
antialiasing at low resolutions.
2018-05-02 16:30:45 +01:00
krzys-h 38a34829af Fix code style in #1150 2018-05-01 21:27:49 +02:00
melex750 a918fcabb4 Fix save/load NewScript programs for factory bots
Fixes #797
2018-04-30 13:43:03 -04:00
AbigailBuccaneer 6f6cfb136a Batch draw calls from CText to improve performance
This significantly speeds up text rendering. On my computer, looking at
the program editor with a full screen of text, this commit takes the
framerate from under 30 to 60 (hitting vsync).

Performance could be further improved in the gl33 renderer by using
instancing or glPrimitiveRestartIndex instead of glMultiDrawArrays, but
that would be a more invasive change.

All of the interface rendering could use a unified quad batching system,
instead of it being limited to CText, but that would require some
refactoring in CText as it currently draws using a different coordinate
space to the rest of the interface.

Fixes #1104.
2018-04-30 10:18:51 +01:00
AbigailBuccaneer c445d7d9a9 Add generic debug rendering functions
Currently the engine can draw debug spheres to show crash sphere
positions. This extends this to draw arbitrary spheres and cuboids,
transformed arbitrarily. With these in place it's now very quick and
easy to create a debug visualisation - for example, it's a one-line code
change to render the bounding box or sphere of every EngineObject.
2018-04-29 23:41:53 +01:00
AbigailBuccaneer 282a793a13 Improve object vis with tighter bounding spheres
This commit improves rendering performance by doing a better job of
checking whether an object is visible via its bounding sphere or not.

The engine maintains a bounding box for each EngineBaseObject that's
exactly large enough to fit every vertex. From this, it computes a
bounding sphere, and only draws objects if the sphere is within the view
frustum. Previously, the bounding sphere was always centered on the
EngineBaseObject's origin, even for models where the bounding box center
is significantly offset from the origin. Now, the bounding sphere is
always the tightest sphere which fits the bounding box.
2018-04-29 19:35:02 +01:00
AbigailBuccaneer c49c815ea5 Set uniforms less often during text rendering
We now call SetWindowCoordinates and SetInterfaceCoordinates once per
string, rather than once or twice per character.
2018-04-27 10:43:26 +01:00
krzys_h fdf67b8217
Merge pull request #1123 from B-CE/i18n
French translation update 1.11
2018-04-24 14:17:43 +02:00
krzys_h db90fcd2ef
Merge pull request #1118 from nextghost/dev
Czech translation
2018-04-24 14:17:23 +02:00
krzys_h 64ab5e3308
Merge pull request #1053 from colobot/dev-a-thing
added a thing
2018-04-24 14:13:42 +02:00
krzys_h 8b86a1f222
Merge pull request #1142 from AbigailBuccaneer/Wmissing-declarations
Compile with -Wmissing-declarations
2018-04-24 14:12:43 +02:00
krzys_h 6289ea91b1
Merge pull request #1140 from AbigailBuccaneer/Wsuggest-override
Compile with -Wsuggest-override under GCC
2018-04-24 14:12:31 +02:00
krzys_h 289b6577d5
Merge pull request #1139 from AbigailBuccaneer/clang-7
Fix building under clang-7
2018-04-24 14:12:15 +02:00
AbigailBuccaneer 4bca2b2243 Fix global sounds being positioned at camera
Certain sounds - such as those coming from the UI - aren't supposed to
sound as if they're coming from a given position. This is currently
accomplished by positioning the OpenAL source at the camera position.
This works, but if the camera position drastically moves during the
sound being played then it's possible to hear the sound fade out.

This pull request makes camera movement no longer affect global sounds,
by specifying their position as being (0, 0, 0) relative to the listener
position.

The easiest way to test this is to start a mission, press E to grab when
there's nothing in front of you, and scroll the mouse wheel quickly.
Pressing E will show the nothing-to-grab message which plays a beep
sound, and scrolling will quickly move the camera. Prior to this pull
request, the sound will fade, after this pull request it won't.

Fixes #1087.
2018-04-24 11:43:11 +01:00
krzys_h 419c430f7e
Jenkinsfile: Make colobot-lint use Clang flags 2018-04-23 19:03:38 +02:00
tomangelo2 5e8be5f6bc Better align of viewpoint UI 2018-04-23 08:12:33 +02:00
AbigailBuccaneer ea64edaa0b Compile with -Wmissing-declarations
-Wmissing-declarations enforces that every function (except for static
functions) must be declared separately before it's defined. This
essentially enforces that every function must be either static, or
declared in a header elsewhere.

This helps the optimizer, as it can do a better job of inlining if it
knows that a function won't be used outside of a given file. It also
helps -Wunused-function (which is enabled by -Wall) find more unused
functions.

Note that Clang spells this option -Wmissing-prototypes, which
confusingly is the name of a related but different warning option under
GCC.
2018-04-21 16:49:27 +01:00
AbigailBuccaneer 4119e669d1 Remove central tracking of SystemTimeStamp
SystemTimeStamp used to be an opaque class, as it was provided by
`system_{linux/other/windows}.h`. Because of this, code dealt in
SystemTimeStamp pointers, and getting the current timestamp required a
memory allocation. Now SystemTimeStamp is just a
`std::chrono::time_point`, we can make the code cleaner and faster by
just directly keeping SystemTimeStamp instead of pointers around.
2018-04-20 09:57:10 +01:00
AbigailBuccaneer 285350464f Remove platform-specific handling of times
Now all platforms use std::chrono::high_resolution_clock and
std::this_thread::sleep_for instead of platform-specific timestamp and
sleep methods.
2018-04-20 09:56:57 +01:00
AbigailBuccaneer 2a003a27b1 Use C++11 threads, mutexes and condition variables 2018-04-20 09:56:57 +01:00
krzys-h e964d3e48c Fix colobot-lint warnings 2018-04-20 02:21:12 +02:00
krzys-h 1c2bdc9cab Update license headers 2018-04-20 02:08:50 +02:00
krzys-h 9f1bd2176f Jenkinsfile: Run colobot-lint 2018-04-20 02:08:50 +02:00
krzys_h 72417fc28b
Jenkinsfile: Switch to declarative syntax
* Switch to declarative syntax
* Test parallel Windows/Linux build
* Remove some hard drive restrictions as now I have more HDD space on the server
2018-04-19 22:11:29 +02:00
AbigailBuccaneer 6978c28ee0 Compile with -Wsuggest-override under GCC
Clang by default compiles with -Winconsistent-missing-override, which
warns when a class declares virtual functions that override those in the
base class, and some but not all of them are explicitly declared
`override`.

GCC doesn't support this option, but has a stronger version,
-Wsuggest-override. In combination with -Werror, this means that any
virtual function that overrides another *must* be explicitly declared as
`override`.

This commit enables -Wsuggest-override where available. This means that
GCC users can't break the Clang build with inconsistent overrides (see
 #1113 and #1114) and consequently that any build that passes the pull
request CI build on Jenkins won't break because of inconsistent
overrides.
2018-04-19 19:58:44 +01:00
AbigailBuccaneer 5cec29f4e6 Fix building under clang-7
Currently the build fails because of -Wdelete-non-virtual-dtor warnings.
This catches when an object is destructed, has a non-virtual destructor,
and is an abstract base class or a non-final class with virtual
functions. The warning happens inside unique_ptr<T>::~unique_ptr.

The warning is to prevent somebody writing code like this:

    class MySceneEndCondition : public CSceneEndCondition {
        ~MySceneEndCondition() { /* some complex logic */ }
    };
    // this won't call MySceneEndCondition's destructor, potentially
    // leading to leaks or segfaults:
    std::unique_ptr<CSceneEndCondition> p{new MySceneEndCondition()};
2018-04-19 10:19:05 +01:00
tomangelo2 2f71cce9c9 Fix camera behaviour when switching to viewpoint 2018-04-15 00:06:04 +02:00
tomangelo2 b04d8d205b Added viewpoints feature
This allows you to set fixed viewpoints in specific location, without attaching to any object, enabling you to track the game from any location.
Proper camera handling will be implemented in next commits.
2018-04-11 21:24:20 +02:00
tomangelo2 ad6dd00275 Change new functions return type and switch to enum class
As suggested by @krzys_h
2018-04-08 23:43:22 +02:00
krzys-h 477dc0cae7 Some CBot code optimizations 2018-04-06 15:02:06 +02:00
krzys_h 0391aaf773
Merge pull request #1114 from B-CE/dev
Fix#1113 - a missing override keyword
2018-04-05 10:24:19 +02:00
B-CE da1b7e8c2d Fixes #274 : pasting tabs 2018-03-12 12:58:43 +01:00
B-CE 9c649cd8b2 Update french translation 2018-03-12 12:46:33 +01:00
B-CE 0e6d22a549 Fix clang compilation, fixes #1113 2018-03-12 12:42:22 +01:00
tomangelo2 d371338920 Fix scoreboard sorting parameters 2018-03-11 17:00:17 +01:00
tomangelo2 1b79e8409f Add switch to determine sort type
You can set it in scene file with ScoreboardSortType SortBy="Name" or "Points"
2018-03-07 21:25:35 +01:00
tomangelo2 ff0f22ef44 Sort scoreboard
First, the team with more points, then which team scored points faster
2018-03-07 15:46:30 +01:00
Martin Doucha 81b4d0e28b Add Czech translation 2018-02-24 20:39:29 +01:00
tomangelo2 5e606336ca Fixed TrackedTrainer tracks allignement 2018-02-12 15:11:14 +01:00
tomangelo2 f51f457023 Narrowed TrackedTrainer tracks
TrackedTrainers now have same width as other bots
2018-02-10 20:58:14 +01:00
Fiftytwo bd0c6d4344 Add PracticeBot helpfile 2017-12-22 17:02:37 +01:00
Fiftytwo a15b3e4dd4 Add Trainer icons 2017-12-22 16:51:25 +01:00
Fiftytwo 0fddd79501 Add PracticeBot alias detection in search() and detect() 2017-12-21 14:44:43 +01:00
Fiftytwo ca0ff013d4 Update Trainer bots 2017-12-21 01:49:56 +01:00
Fiftytwo 94aa76e7a1 Add auto object detection for takeoff, destroy, camerafocus 2017-11-30 20:41:44 +01:00
Fiftytwo e01a6bd0ef Add Builder documentation 2017-11-30 08:00:17 +01:00
Fiftytwo 7eb1df4119 Add aim recalibration during falling 2017-11-29 13:24:05 +01:00
Fiftytwo db23c6eecf Change Builder default camera type 2017-11-25 14:35:45 +01:00
Fiftytwo 5f8b7a8149 Update BotFactory interface 2017-11-25 12:30:16 +01:00
Fiftytwo e8b93f6cda Add Builder interface 2017-11-25 03:09:47 +01:00
Fiftytwo 614dc5e591 Builder research 2017-11-23 00:11:29 +01:00
krzys-h 7f6c0cd31e added a thing 2017-11-22 18:29:09 +01:00
Fiftytwo 03c7d2e7ee WingedBuilder full implementation; new aiming method, better particle alignment 2017-11-22 02:05:36 +01:00
Fiftytwo d06116eb49 Attached proper particles to the neutron gun 2017-11-21 19:09:38 +01:00
Fiftytwo b72e802ff7 Neutron gun now aims 2017-11-17 19:57:08 +01:00
Mateusz Przybył 46bef8fd92
Add button4.png drawing (builder icons) 2017-11-17 18:59:14 +01:00
Mateusz Przybył d470d9e63c
Update data submodule (button4.png) 2017-11-17 18:56:34 +01:00
Mateusz Przybył d072680715
Gitignore /.idea folder 2017-11-17 18:55:57 +01:00
Fiftytwo 0b36bdf37f Quick fix for 9a33551 since I broke sth 2017-11-17 12:00:49 +01:00
Fiftytwo 9a33551a03 Reverted factory() to its original design; reworked syntax of other object.functions() accordingly; improved compatibility with CeeBot4 SCHOOL 2017-11-17 11:32:50 +01:00
tomangelo2 37fab2fad2 Updated data submodule 2017-11-16 22:46:34 +01:00
Fiftytwo b04d8ca99d Clean up redundant files 2017-11-16 20:32:10 +01:00
Fiftytwo a024866fd3 Builder bots base implementation 2017-11-16 18:43:45 +01:00
krzys-h b5cc7689d1 Release 0.1.11-alpha: Bump version 2017-11-10 11:01:25 +01:00
krzys-h adda82819c Post-release 0.1.11-alpha 2017-11-10 11:01:25 +01:00
krzys-h b143aa38ac Release 0.1.11-alpha: Merge branch 'dev' 2017-11-10 11:01:24 +01:00
krzys-h 611c353060 Update release script 2017-11-10 11:01:09 +01:00
krzys-h f87aa15bb2 Update data submodule 2017-11-10 09:28:39 +01:00
tomangelo2 f01e2b7e01 Moved fonts maps from header file to source file 2017-11-07 19:29:51 +01:00
krzys-h 5f5e5234fc Fix CEdit background margins, closes #1029
This mismatch happened after changes in 08d87fa975
2017-11-04 11:56:15 +01:00
krzys-h 5021a4091e Update data submodule 2017-11-04 11:42:27 +01:00
krzys-h b89b0d2703 Update data submodule 2017-11-04 11:35:40 +01:00
krzys-h 12dd96c3b2 Update data submodule 2017-11-04 11:28:24 +01:00
krzys_h d3b969fb4d
Merge pull request #992 from DavivaD/dev-dmgalarm-st2
Damage Alarm Implementation (2th Stage)
2017-11-04 11:27:14 +01:00
krzys_h 17d47e9b63
Merge pull request #1040 from melex750/dev
Saved game bug fix
2017-11-04 11:24:09 +01:00
krzys-h 387b7b5396 Fix non-scoreboard code battles, closes #1023 2017-11-04 11:23:17 +01:00
tomangelo2 0179e4c786 Cleaned unused values from CFontConfig 2017-10-28 22:24:11 +02:00
tomangelo2 ff97df74c6 Added support for italic and bold variants of studio and satcom fonts
They aren't currently used anywhere
2017-10-28 22:22:22 +02:00
melex750 d357de1438 Save object lifetime and abstime
Fixes #1006
2017-10-24 05:12:19 -04:00
melex750 1eee06d9f9 Keep mission history after loading a crashsave
Fixes #812
2017-10-24 04:55:22 -04:00
melex750 a9e0874abc Fix 'this' for object:: functions
Fixes #672
Fixes #1026
2017-10-24 04:46:07 -04:00
tomangelo2 3801ab87a2 Changed m_font map to const fontType map 2017-10-23 19:08:28 +02:00
krzys_h 6b1dd5dd8b Merge pull request #994 from DavivaD/dev-issue-658
Thumper & Recycler Enhancements.
2017-10-22 18:22:06 +02:00
krzys_h ee0f3ff5fd Merge pull request #1022 from immibis/dev
Fix horizontal scrolling of planets and background images
2017-10-22 18:21:49 +02:00
krzys_h 9448f6712f Merge pull request #1004 from melex750/dev-cbot
Escape codes for strings in CBOT
2017-10-22 18:20:50 +02:00
krzys_h 0a83508547 Merge pull request #985 from melex750/dev
Bug fix for CStudio
2017-10-22 18:20:35 +02:00
tomangelo2 1539e94b09 Changed defaultFont to const map 2017-10-18 20:40:07 +02:00
tomangelo2 76a8335501 Reworked GetFont method 2017-10-18 12:01:34 +02:00
DavivaD 2a0c2c38f0 Make shortcut blink in red 2017-10-17 02:35:33 +02:00
melex750 bf69b86233 Fixed shortcut not changing to normal state 2017-10-17 02:33:05 +02:00
tomangelo2 dab223e6ce Clamp energy level to standard values for OrgaShooters
Fix issue #1009
2017-10-16 20:29:59 +02:00
tomangelo2 94cacdae96 Removed singletone from FontConfig
Also renamed class so it now matches better with class file name
2017-10-15 23:46:15 +02:00
tomangelo2 1e614d64d0 Removed unnecessary variable 2017-10-15 23:35:09 +02:00
tomangelo2 52d9330114 Replaced multiple methods with one 2017-10-15 23:31:06 +02:00
tomangelo2 dd9439aed2 Renamed font_file to font_config 2017-10-15 22:47:32 +02:00
tomangelo2 f40756bc46 Fix turn(1) doesn't draining energy
Fix using @Melex750 example, thanks!
Fix issue #136
2017-10-11 18:50:57 +02:00
tomangelo2 054d1c3e54 Changed in-engine fonts names 2017-10-11 17:10:04 +02:00
tomangelo2 cf46c2457a Moved file font.ini to /fonts/ directory
Separated SatCom font from Colobot font
2017-10-11 17:02:09 +02:00
tomangelo2 250c934b9e Added fonts configurability by a separate file 2017-10-09 00:36:31 +02:00
immibis 8b0ccf6667 Fix horizontal scrolling of background images. 2017-08-05 20:08:00 +12:00
immibis 2e8798b33d Make planets stay in one place in the sky - at least in the X direction. 2017-08-05 20:08:00 +12:00
immibis 2751db3245 Add horizontal FoV to CEngine 2017-08-05 19:45:08 +12:00
DavivaD ee35d35db3 Correct Small Mistake 2017-07-27 02:02:46 +02:00
DavivaD 959854ec59 'Make Thumper Great Again' 2017-07-26 23:05:53 +02:00
tomangelo2 0de347d430 Fixed goto() behaviour on 32-bit binaries
Closes issue #844
2017-07-26 14:54:04 +02:00
DavivaD a4482f1a7c Decrease radius of squashing items. 2017-07-24 23:20:21 +02:00
melex750 e3c44e956f Add syntax highlighting for escape codes 2017-07-22 14:30:05 -04:00
melex750 c03dfc1284 Add escape codes for string literals 2017-07-22 14:29:05 -04:00
DavivaD b5e0f9966f Make Recycler Recycle small Building Ruins. 2017-07-21 20:37:18 +02:00
DavivaD bef6e9eceb Make Thumper Squash transportable/small objects. 2017-07-21 20:36:31 +02:00
melex750 86870167a6 Fix moving and resizing open/save dialog
* Fixed buffer overflow when resizing
* Stop hard drive thrashing when moving/resizing
2017-06-26 14:19:53 -04:00
melex750 2d2990ff91 Fix moving and resizing editor/debugger window
* Stop hard drive thrashing when moving/resizing
* Also fixed #691.
2017-06-26 14:11:47 -04:00
DavivaD a29a4f93ac Damage Alert Implementation (2th Stage) 2017-06-20 23:35:33 +02:00
tomangelo2 75d9f8573b Display warning if no quicksave slot is found 2017-06-11 23:29:50 +02:00
tomangelo2 d63ed865f4 Added QuickSave/QuickLoad feature #929
Also rearranged a bit speed control buttons to make some space for it
F5 - QuickSave
F6 - lower speed (current/2)
F7 - reset speed
F8 - higher speed (current*2)
F9 - QuickLoad
2017-06-11 17:50:21 +02:00
krzys-h d860a08d21 Merge long first frame rendering fix from #898
Also did some changes to make sure the "F1 to open SatCom" appears immediately (not after 0.1s),
and that mission timer won't start ticking in the first simulation frame (mainly for code battle initial pause)
2017-06-04 13:10:50 +02:00
krzys-h 25c79df65f Update data submodule 2017-06-03 21:53:48 +02:00
krzys-h bb35585194 Fix object.factory() code type detection, closes #938 2017-06-03 21:43:10 +02:00
krzys-h ac27bdac4a Update data submodule 2017-06-03 21:32:28 +02:00
krzys-h 5d0e58fcb3 Update data submodule 2017-06-03 21:19:34 +02:00
krzys-h 8d9b36333b Update data submodule 2017-06-03 21:15:55 +02:00
krzys-h 4faabf2185 Apply shadow mapping performance counter patch from #923 2017-06-03 21:11:18 +02:00
krzys-h a95f736cbe Fix delete(this.id), closes #925 2017-06-03 20:05:54 +02:00
krzys_h bf94bd7130 Merge pull request #965 from melex750/dev
Improved search() and searchall()
2017-06-03 18:56:29 +02:00
krzys-h 199210c2ad Merge branch 'master' into dev
See 92a8140b77
2017-05-29 21:13:17 +02:00
krzys-h 92a8140b77 Jenkinsfile: prevent PRs to master
I just merged a PR to master by mistake. Whoops! Let's not let that happen again.
2017-05-29 21:09:50 +02:00
krzys-h 8058a89cde Merge branch 'master' into dev
I messed up and merged #967 into master by mistake, but since it's only a change to README I won't bother reverting it
2017-05-29 20:53:46 +02:00
Andrey daacd0036f INSTALL-MacOSX.md: Add missed xmlstarlet dependency (#967) 2017-05-29 20:50:13 +02:00
Abigail f4614658cf Fix -Wundefined-var-template warning (#963)
This avoids specializing CSingleton<T>::m_instance for each type, and
instead just defines it once in the header. This is allowed by the
standard, multiple definitions are merged in the same way that inline
functions are.
2017-05-29 20:46:11 +02:00
melex750 15b8cf7f78 Update object variable when concatenating strings 2017-05-25 02:09:44 -04:00
melex750 30210d0de7 Add searchall() and improve search() function 2017-05-25 02:01:42 -04:00
krzys-h 621911eb64 Release 0.1.10-alpha: Bump version 2017-05-24 14:34:19 +02:00
krzys-h 36cd5eeea9 Post-release 0.1.10-alpha 2017-05-24 14:34:19 +02:00
krzys-h 1dcc70c097 Release 0.1.10-alpha: Merge branch 'dev' 2017-05-24 14:34:19 +02:00
krzys-h 8269f79173 Update data submodule 2017-05-24 14:33:34 +02:00
krzys-h 02aa281d30 Remove unnecessary m_instance declarations
They don't do anything at all in gcc and clang, but cause compile errors in MSVC
see #955
2017-05-24 14:00:34 +02:00
krzys-h 28081bfd3e Fix clang builds
see #955
2017-05-24 14:00:34 +02:00
RaptorParkowsky 6c8ec46725 Update data submodule 2017-05-24 13:43:51 +02:00
krzys-h 1f477bbc86 Fix error in edit.cpp in 08d87fa975 2017-05-24 12:46:30 +02:00
krzys-h 7216d8d12e Fix crash after exiting a code battle 2017-05-24 12:42:37 +02:00
krzys-h 08d87fa975 Make initial scoreboard values editable 2017-05-24 12:39:05 +02:00
krzys-h f60108f367 Prevent enforcement of ObligatoryToken for level controller scripts 2017-05-24 10:50:43 +02:00
krzys-h 935b789d02 Fix alien animations after 5d4dfd8cb5 2017-05-24 10:45:31 +02:00
krzys-h 5d4dfd8cb5 Fix scoreboard points sometimes being added multiple times 2017-05-23 22:25:40 +02:00
krzys-h d8b0bd4df8 Make TargetBots explode when they run into something 2017-05-23 22:02:00 +02:00
krzys-h 149d1f8156 Fix aliens not appearing on the minimap, closes #901 2017-05-23 20:51:37 +02:00
krzys-h 004106eb19 Don't limit types of objects visible on minimap with fixed image 2017-05-23 20:47:03 +02:00
krzys-h 648dfd75c4 Fix handling of particle 'father' objects when they are destroyed 2017-05-23 20:31:55 +02:00
krzys-h 904b7e580b Prevent giving scoreboard points to team 0 2017-05-23 20:20:46 +02:00
krzys-h 2d7911f155 Fix delete() in CBot not destroying PowerCells properly 2017-05-23 20:19:47 +02:00
krzys-h aa1a946336 Make deprecation warnings not an error, see #958 2017-05-23 19:02:17 +02:00
MatiRg 417301ff06 Fix rendering glasses in FPP camera, closes #775 (#959) 2017-05-23 18:57:41 +02:00
krzys-h 108551c199 Fix @tomangelo2's code style
see 47a8f70f0f
2017-05-22 11:11:44 +02:00
Abigail 11d950221b Fix all compiler warnings and enable -Werror (#955)
This removes all compilation warnings on:
* g++ 4.7.4, 4.8.5, 4.9.4, 5.4.1, 6.3.0, 7.0.1-svn246759
* clang++ 3.9.1, 4.0.0, 5.0.0-svn303007
2017-05-22 11:10:35 +02:00
Ceeee 5055c5de11 Updating German locale (#849)
Filled open gaps and tried to clarify some instances (native speaker)
2017-05-22 11:06:15 +02:00
krzys-h 24460ea979 Update data submodule 2017-05-22 11:04:44 +02:00
DavivaD df12f87b47 Implement damage alarm (#916)
Implements part of #320
2017-05-22 11:01:36 +02:00
krzys_h cd808ac59f Merge pull request #920 from melex750/dev
Fix default arguments
2017-05-22 10:58:16 +02:00
MatiRg a0e5cc25e1 Allow ctrl + backspace in the editor. (#839) 2017-05-22 10:57:30 +02:00
krzys-h 7b328fbfc3 Make UraniumOre not destroyable, closes #777
This was likely a mistake during object interface refactoring
2017-05-21 21:45:46 +02:00
krzys-h 44d18b77be Jenkinsfile: Don't keep artifacts for old PR builds 2017-05-21 20:59:43 +02:00
krzys-h 92eb202d5d Jenkinsfile: Automatically clean workspace after building pull requests 2017-05-21 20:59:30 +02:00
krzys-h 4bb05b32f5 Jenkinsfile: Update deprecated 'stage' syntax 2017-05-21 20:59:00 +02:00
tomangelo2 47a8f70f0f Display warning if there is not enough energy to shoot
Fix issue #949
2017-05-20 20:41:30 +02:00
krzys-h 681d5203e5 Make code battle start button header translatable 2017-05-19 21:23:14 +02:00
krzys-h c68f5e276f Add live scoreboard display 2017-05-19 21:11:43 +02:00
krzys-h b3ea687d32 Minor documentation fixes 2017-05-19 20:15:13 +02:00
krzys-h 8948da0612 Add Barricade objects 2017-05-19 15:33:44 +02:00
krzys-h 327eafddb7 Add order= parameter for ScoreboardEndTakeRule 2017-05-18 20:39:32 +02:00
krzys-h 6bebbb3f70 Fix sky rendering artifact 2017-05-18 19:03:19 +02:00
krzys-h f6cc629054 Log correct terrain relief resolution 2017-05-18 18:32:22 +02:00
krzys-h cf7c19ef62 Make teams and scoreboard translatable 2017-05-17 19:00:40 +02:00
krzys-h 880f31a7c6 Add basics of scoreboard implementation; better support for multiple teams 2017-05-17 18:22:58 +02:00
krzys-h 6cd72543c4 Fix amount of damage from OrgaShooters
I messed it up in previous commit, 0.002/2 is 0.001 not 0.0005 :P
2017-04-29 13:18:01 +02:00
krzys-h fda58a6008 Change bullet collision logic to allow for collisions with non-damageable objects
For now, you have to add bulletWall=true to objects you want bullets to collide with.
It's ugly but will work for now. This is needed mostly for compatibility
with exercises which use barriers to block movement but not bullets.

I also made the collision checks run more often because otherwise the bullets
would sometimes miss the objects (but only visually)
2017-04-29 13:14:10 +02:00
melex750 f80db9e8fb Fix using negative numbers in default arguments
Issue #919
2017-03-03 02:11:10 -05:00
melex750 b032dad578 Fix execution of default arguments 2017-03-03 01:09:09 -05:00
tomangelo2 588bf30b94 Fixed some functions doesn't returning 0 if no error
Fix issue #917
2017-03-02 23:01:55 +01:00
krzys_h ac3fd15c5a Merge pull request #911 from abenkovskii/patch-1
Remove a dead link to the dev wiki
2017-02-15 20:05:03 +01:00
Андрей Беньковский 3934eec902 Remove a dead link
The wiki is dead now. See c03d8beb8b
2017-02-15 20:19:40 +04:00
MrSimbax 992ca7e842 Update data submodule 2017-02-12 12:24:17 +01:00
krzys-h 9eae1e151d Fix Shooter target getting stuck on not selectable objects (#900) 2017-01-28 12:56:42 +01:00
krzys-h 7fadf7bad5 Fix aliens being selectable by default (#900)
Broken in 6a382830a9
This change also allows you to make selectable insects with selectable=1 in scene file
2017-01-28 12:53:28 +01:00
krzys_h 967fb9e30f Merge pull request #897 from melex750/dev
* Fix game crashing related to syntax errors
* Fix problems with not returning correct value from function
* Add default values for parameters
* Fix custom functions not accepting nan
* Fix 'point' constructor not executing when called with new
2017-01-26 18:46:42 +01:00
melex750 92a8c48953 Add syntax for parameters with default values
Also fixes #642
2017-01-24 15:19:03 -05:00
melex750 baba6081b3 Add checking for return statements in functions
issue #30
2017-01-24 14:41:22 -05:00
melex750 2ff8251a81 Fix game crashing with syntax errors 2017-01-24 13:47:00 -05:00
melex750 8e54f7ca9c Fix memory leaks in CBOT engine 2017-01-16 21:16:59 +01:00
melex750 64bc1f1afb Fix constructor/destructor and field syntax 2017-01-16 21:16:59 +01:00
melex750 8fc0151444 Fix increment and decrement syntax 2017-01-16 21:16:59 +01:00
piotrwalkusz1 d7fae300b9 Fix crash on class redefinition, closes #703 (#890) 2017-01-15 20:28:52 +01:00
Smok94 8a0c7279dc Command history for cheat console, closes #316 (PR #869)
Adds console command history. Browsable by up and down arrow keys.
2017-01-02 20:23:19 +01:00
piotrwalkusz1 6ec13017eb Fix apperance camera position, closes #802 (#880) 2017-01-02 18:43:19 +01:00
Tomasz Kapuściński 9bdd83771e Optimizations and changes in OpenGL 2.1 device.
* Limited number of lights to 4
* Only directional lights
* Per-pixel lighting
* Improved dynamic shadows a bit
2017-01-02 16:35:40 +01:00
krzys-h 7b3b257580 Fix code style 2017-01-02 14:54:38 +01:00
Tomasz Kapuściński 7bb3245092 Optimizations and changes in OpenGL 3.3 device.
* Limited number of lights to 4
* Only directional lights
* Per-pixel lighting
* Improved dynamic shadows a bit
* Optimized texture changes
2017-01-01 17:16:54 +01:00
krzys-h 46aa6fc907 Some CRobotMain cleanup
* improved documentation
* renamed cheat variables to include the word "cheat" to make it clearer what they do
* removed some useless members
2016-12-27 23:38:57 +01:00
krzys-h 6a382830a9 Allow selectinsect to select other objects with selectable=0 2016-12-27 22:20:58 +01:00
krzys-h 17511ddb6a Fix some code style 2016-12-27 15:54:52 +01:00
krzys-h f33ffaf18b Fix mission end before astronaut death scene is finished (#848) 2016-12-27 15:32:38 +01:00
krzys-h 5722fdb163 Fix bug (?) related to lost cutscenes
This was here since the original game, probably unused but I fixed it anyway
2016-12-27 15:21:49 +01:00
krzys-h 8d52e27c2b Add coordinates under cursor overlay and copy function (#868) 2016-12-27 14:58:41 +01:00
krzys-h b6cda6cd4c Add error when object is busy (#871) 2016-12-27 13:36:46 +01:00
krzys-h e325efa447 Fix crash after precompiling a CBot class with errors (#881) 2016-12-27 13:23:41 +01:00
Стуров Фёдор f0550383d1 Add missing russian translations (#852) 2016-12-22 19:13:34 +01:00
Martin Quinson 8ce8b2fff3 update french translation 2016-12-22 18:11:20 +01:00
tomangelo2 5dc38f1526 Objects outside BuildType list cannot be build anymore
Fix issue #863
2016-12-05 14:16:11 +01:00
krzys-h eb2a1857dc Fix goto() with multiple objects at the exact same position (#732) 2016-12-04 16:07:41 +01:00
krzys-h 88c6818cfd Fix code style issues 2016-11-26 13:48:12 +01:00
krzys-h be9dba4788 Jenkinsfile: Automatically discard old artifacts 2016-11-26 13:01:43 +01:00
krzys-h 7190c8518e Fix destructors not being called when program execution ended, closes #859 2016-11-11 23:07:22 +01:00
krzys-h b49fbf0cd6 Another this==nullptr fix (#828) 2016-11-11 22:58:39 +01:00
krzys-h 48f703282e Refactor CBotCallMethode -> CBotExternalCall 2016-11-11 21:58:25 +01:00
krzys-h 6b7233c6ae Remove CBotLinkedList from CBotFunction
Fixup for 191151eb7b
No idea how I managed to forget that
2016-11-11 19:47:59 +01:00
krzys-h 35d60aaae5 Remove remaining occurences of "this == nullptr" (#828) 2016-11-11 19:45:57 +01:00
krzys-h 191151eb7b Refactor CBotClass and CBotFunction list to std::list 2016-11-11 19:37:19 +01:00
krzys-h 266b34d578 Make CBotFunction implement CBotLinkedList 2016-11-11 18:16:12 +01:00
krzys-h 8764d28e9e Remove remaining "this != nullptr" checks in CBOT, closes #828 2016-11-11 18:03:46 +01:00
krzys-h 3bac0aabd9 Fix buffer overrun when rendering goto() debug texture, closes #841 2016-11-11 17:26:37 +01:00
krzys-h 856ee9a0fe Don't allow whitespace player names, closes #840 2016-11-11 17:13:32 +01:00
krzys-h 6e4764b97c Fix GroundSpot blending, closes #846 2016-11-11 17:06:53 +01:00
krzys-h 1b074bd94d Fix crash on loading saves with produce()d objects (#765)
Thanks @melex750!
2016-11-11 13:38:43 +01:00
Tomasz Kapuściński e7c41ae9e6 Correction in changing wrap mode in SetState 2016-11-10 13:00:42 +01:00
Tomasz Kapuściński 9fe85e280a Code simplification in CGL14Device 2016-11-10 12:34:30 +01:00
Unknown 3c71354b42 Fix MSVC2015 compilation error 2016-11-07 21:08:02 +01:00
Tomasz Kapuściński 5aa5d91ecb Fix compilation errors in half.cpp 2016-11-04 18:34:49 +01:00
Tomasz Kapuściński 993d9e9ed6 Added rendering with generic vertex formats 2016-11-04 14:13:16 +01:00
Tomasz Kapuściński ae3b2b8572 Added types and vertex format specification 2016-11-04 11:59:57 +01:00
Tomasz Kapuściński c5b5435b4a Added half-precision floating-point format implementation 2016-11-04 11:35:55 +01:00
krzys-h b8d88c97b0 Release 0.1.9-alpha: Bump version 2016-11-02 21:42:23 +01:00
krzys-h 81c7d05d7c Post-release 0.1.9-alpha 2016-11-02 21:42:23 +01:00
krzys-h b0e34bbe6a Release 0.1.9-alpha: Merge branch 'dev' 2016-11-02 21:42:22 +01:00
krzys-h d43562883e Remove unused imports from release.py 2016-11-02 21:40:52 +01:00
krzys-h 70853f2b86 Add temporary hack for issue #828 2016-11-02 21:38:47 +01:00
krzys-h 3c1bf3c014 Added script for use when releasing new versions 2016-11-02 21:31:34 +01:00
MrSimbax 81f4436951 Update data submodule 2016-11-02 20:17:36 +01:00
MrSimbax ef28b0dd14 Update data submodule 2016-11-01 19:36:11 +01:00
MrSimbax fee1619c9c Update data submodule 2016-10-24 23:16:10 +02:00
krzys-h bb9d1c8265 Remove "this == nullptr" checks in CBOT, fixes #828 2016-10-02 21:36:59 +02:00
krzys-h a96835e35f Change CBot file log messages
Open mode is logged now. Additionally fixed incorrect file path in log when deleting files.
2016-09-30 17:08:37 +02:00
MatiRg d107605007 Add file append mode in CBot (#838) 2016-09-30 17:03:13 +02:00
krzys-h 73be03161f Fix infinite pause when cloning program with errors, closes #837 2016-09-27 18:57:24 +02:00
krzys-h 3472ec6613 Revert CParticle::CheckChannel changes
I misinterpreted this as being a bug, while actually it seems to be an explicit CParticle design choice (maybe not the best one, but whatever). We DO need better docs for some old code like this :/

Fixes #806

This reverts commit 99a831a03b.
2016-09-27 18:34:54 +02:00
MatiRg dc415c3d2a Remove character limit in CEdit (#836) 2016-09-25 19:13:04 +02:00
krzys_h 89bf0da30c Merge pull request #834 from melex750/dev
Implicit cast and null when passing arguments
2016-09-24 17:13:17 +02:00
krzys-h ca548e2902 Update CBotFieldExpr::ProtectionError docs 2016-09-24 17:04:47 +02:00
krzys-h 81aae35565 Updated translation files after 4a14a44f3f 2016-09-24 16:48:27 +02:00
melex750 9ab7f7d140 Fix access to protected and private variables 2016-09-17 08:00:34 -04:00
melex750 3debfb9182 Fix finding in-class methods when searching by ID 2016-09-17 07:59:34 -04:00
melex750 4a14a44f3f Add implicit cast and null for passing arguments 2016-09-17 07:58:39 -04:00
Unknown 6b6eca61cb Update data submodule 2016-09-13 10:15:28 +02:00
Unknown ade8566d06 Update data submodule 2016-09-10 17:51:52 +02:00
krzys_h 84c98546df Merge pull request #819 from melex750/dev
Method chaining for constructor calls in CBOT
2016-09-09 19:37:37 +02:00
krzys_h 8dc03f40d5 Merge pull request #817 from CyborgMaster/radarall-equidistant-objects
radarall can return multiple objects with exactly the same distance
2016-09-09 19:17:40 +02:00
Unknown e3b3d7c9aa Enable debug info for MSVC 2016-08-24 18:18:33 +02:00
Unknown e085b4b422 Enable C++ exceptions in MSVC
Because warnings.
2016-08-24 13:34:51 +02:00
MrSimbax 514829de60 Normalize dir parameter when copying to clipboard 2016-08-20 13:22:53 +02:00
MrSimbax 974b6efad5 Add -pedantic-errors flag to C++ compilers 2016-08-18 12:59:29 +02:00
MrSimbax 92b1e544ec Remove default lambda parameters
They cause compilation error on MSVC and should give errors, as it's explicitly stated in the C++11 standard: http://stackoverflow.com/questions/6281472/why-does-a-default-argument-for-a-lambda-argument-trigger-a-pedantic-gcc-warni
2016-08-18 10:02:54 +02:00
MrSimbax 584d782a9f Add VS Code files to .gitignore 2016-08-15 18:08:18 +02:00
melex750 3146d4ef35 Add method chaining for class constructor calls 2016-08-14 16:56:17 -04:00
Jeremy Mickelson 859cec774a Added comment explaining container choice 2016-08-13 12:18:54 -06:00
Jeremy Mickelson 88227a3647 Allow multiple objects with exactly the same distance to be returned by `radarall` 2016-08-13 12:13:41 -06:00
krzys-h d411c5ebc0 Allow circular references from different classes (#814)
Conflicts:
	test/unit/CBot/CBot_test.cpp
2016-08-09 21:10:07 +02:00
melex750 71aa7e468b Add unit tests for circular reference 2016-08-09 14:55:56 -04:00
krzys-h b9d4d57e33 Syntax sugar: Accessing members of returned objects (#808)
Conflicts:
	src/CBot/CBotInstr/CBotInstrMethode.h
2016-08-09 20:28:37 +02:00
krzys_h d83553ca14 Merge pull request #809 from melex750/dev
Fixes and unit tests for inheritance
2016-08-09 19:23:49 +02:00
krzys-h 0ecdee08cc Merge branch 'dev-async-music-load' (PR #801) 2016-08-09 19:20:46 +02:00
krzys-h 4cb2eb6d37 Removed fuzzy markers for lines fixed in #805 2016-08-09 19:07:50 +02:00
aleksei-sh 191ca3c4eb Reducing the length of the lines
The length of lines is reduced so that they fit in the interface
2016-08-09 19:04:32 +02:00
aleksei-sh 1546c1514a Filled not existed translation, minor translation changes
Fill empty lines. Some translations has been corrected ("вы" required form "нажмите";  project name "Colobot" can not be translated to "КОЛОБОТ").
2016-08-09 19:04:22 +02:00
melex750 66218319dd Add support for circular references
Issue #433
2016-08-09 11:59:07 -04:00
melex750 8b3c4302d2 Add more unit tests for inheritance 2016-08-07 10:01:10 -04:00
Jeremy Mickelson 6b8e240d26 Fix implicit downcast with variable initialization 2016-08-07 08:27:01 -04:00
melex750 a205eace38 Add missing license headers 2016-08-06 16:29:02 -04:00
melex750 f3bf56d9e3 Add unit tests for returned object member access 2016-08-06 05:22:40 -04:00
melex750 e48188b429 Fix failed assert when literal null is returned 2016-08-06 04:56:57 -04:00
krzys-h c03d8beb8b Import documentation from old dev wiki
I also updated all outdated information I could find, please tell me if I missed something

Model format documentation needs an update
2016-08-05 17:04:16 +02:00
melex750 fad38cd0e9 Add accessing members to function calls 2016-08-04 03:16:59 -04:00
melex750 c89e6f4c28 Begin adding unit tests for inheritance 2016-08-04 01:19:56 -04:00
melex750 c9c02f5461 Fix assigning instance to pointer for inheritance 2016-08-04 01:06:37 -04:00
melex750 860cdb0aea Fix calling multi-level inherited methods 2016-08-03 19:13:21 -04:00
melex750 d0a8a32a57 Fix RestoreMethode when calling inherited methods 2016-08-03 18:34:39 -04:00
melex750 397e312424 Fix RestoreState for subclass instance vars 2016-08-03 17:52:53 -04:00
melex750 48666c4604 Fix not calling destructors after save/reload 2016-08-03 17:42:10 -04:00
krzys-h 210b5c295d Fix memory leak related to performance counters
This commit actually fixes two problems causing the leak:
* DestroyTimeStamp not being called in CProfiler (my stupid mistake in 5fea22ff03)
* DestroyTimeStamp leaving null pointers in CSystemUtils::m_timeStamps (this was introduced by @piotrdz long ago when introducing smart pointers)
2016-07-24 22:51:41 +02:00
krzys-h dbe7fd6ef0 Added performance counter for UI particles 2016-07-24 18:19:37 +02:00
krzys-h 716218aa37 Fixed compile error on Windows 2016-07-24 18:19:34 +02:00
krzys-h ffd688e2d7 Do not render the shadow map when pause blur is active 2016-07-24 16:56:47 +02:00
krzys-h fef050f6dd Fixed loading apperance scene, closes #802 2016-07-24 16:44:27 +02:00
krzys-h 2c3e90b126 Added CBot performance counter 2016-07-24 16:36:13 +02:00
krzys-h 5fea22ff03 Moved performance counters to a separate class 2016-07-24 16:18:25 +02:00
krzys-h 81b7bcc5bc Moved system modules from app/ to common/system/ 2016-07-24 14:38:49 +02:00
krzys-h aa6345ab5e Post-release 0.1.8-alpha 2016-07-11 09:29:50 +02:00
krzys-h 407d855466 Release 0.1.8-alpha: Bump version 2016-07-11 09:27:53 +02:00
krzys-h 2b63369060 Release 0.1.8-alpha: Merge branch 'dev' 2016-07-11 09:27:01 +02:00
krzys-h 19cc25f716 Fixed sound channels not being unmuted properly 2016-07-10 20:12:44 +02:00
krzys-h 29f0631a2c Asynchronous sound/music loading
This improves the loading time a lot. Time from starting the app to opening game window decreased by almost 5 seconds (it's almost instant now). Mission loading times are significantly better too. As a bonus, the playmusic() CBot function doesn't hang the game if you don't preload the files with CacheAudio in scene file.
2016-07-10 14:56:34 +02:00
krzys-h 9e545d0d39 Fixed colobot-lint warnings 2016-07-09 20:39:18 +02:00
krzys-h 8a17bc901c Added pause blur config setting, enabled by default 2016-07-09 12:13:51 +02:00
krzys-h 9b9dd43c2a Updated data submodule 2016-07-04 20:36:03 +02:00
krzys-h 6f412df232 Fixed lockups when calling StartSuspend multiple times 2016-07-04 17:02:39 +02:00
krzys-h fb3245977c Added logging to CPauseManager 2016-07-04 17:01:48 +02:00
krzys-h 58815059ea Added warnings about planned changes to EndMisisonTake (#759) 2016-07-04 16:30:22 +02:00
krzys-h 7bfe9fdd0a Updated data submodule 2016-07-04 13:23:37 +02:00
krzys-h 11d40197ee Added some more CBot tests after #793 2016-07-04 12:23:48 +02:00
krzys-h 3e30ccfdfa Merge pull request #793 from melex750/dev
Fix some bugs in CBOT

This fixes https://github.com/colobot/colobot/issues/728#issuecomment-205039570 and #626
2016-07-04 12:20:39 +02:00
melex750 d0d0c4f197 Fix class not unlocked when program is stopped
#626
2016-06-24 17:29:32 -04:00
melex750 64157090e6 Fix crash when calling method on a null object 2016-06-24 17:18:11 -04:00
melex750 51665e8396 Fix "new" keyword syntax checking 2016-06-24 17:03:50 -04:00
melex750 66984a4bb3 Fix using compound-assignment with an array
...that was initialized in the definition
2016-06-24 17:00:41 -04:00
melex750 0d74b4f36b Fix initializing an array using variables
Resolves a conflict between CBotListArray and CBotExprVar
2016-06-24 16:56:17 -04:00
krzys-h 3b9b9b322a Changed mouse scaling (again) 2016-06-21 13:07:40 +02:00
krzys-h 0fbd2d107c Allow using the CBot debugger during code battles 2016-06-21 13:06:55 +02:00
krzys-h c304ecd0ca Changed arrays to use {} when converted to string; added tests 2016-06-21 12:58:43 +02:00
krzys-h 5f7a8dbd5d Fixed string values with spaces (closes #791) 2016-06-21 12:57:45 +02:00
krzys-h 8ad53ce327 Fixed pause blur in main menu 2016-06-19 22:18:03 +02:00
krzys-h bd4362e26c Fixed dynamic textures not being reloaded properly 2016-06-19 19:57:55 +02:00
Tomasz Kapuściński a0b3f7a769 Fixed problem with pause blur after changing some graphic settings 2016-06-19 16:52:01 +02:00
krzys-h 125d1a32c7 Fixed pause blur blinking for one frame
issue #656
2016-06-19 12:23:57 +02:00
krzys-h 9d9131c3fb Fixed pause blur with MSAA
issue #656
2016-06-19 11:45:59 +02:00
krzys-h 543df84db6 Enabled more tests
See https://github.com/colobot/colobot/pull/783#issuecomment-226963085
2016-06-18 22:31:32 +02:00
krzys-h f0ed20fd67 Enabled working tests after bf2e3cdfae 2016-06-17 22:49:15 +02:00
krzys-h bf2e3cdfae Merge pull request #783 from melex750/dev
[INFO] Conversion to string
2016-06-17 22:41:53 +02:00
krzys-h 7ce23fdf52 Do not rotate after changing autosave settings
See https://github.com/colobot/colobot/pull/789#discussion_r67570610
2016-06-17 22:39:45 +02:00
krzys-h 439a416a66 Merge pull request #789 from Erihel/dev-boost-filesystem-removal
Dev boost filesystem removal
2016-06-17 22:38:41 +02:00
krzys-h cd18341330 Updated data submodule 2016-06-17 21:21:34 +02:00
krzys-h 9017e5a25b Fixed links in CBot listings in SatCom 2016-06-17 21:13:16 +02:00
Krzysztof Dermont 32629a2f2a Refactor autosave rotation.
In order to remove boost:filesystem from CResourceManager Move()
function has to be removed or rewrited. Since Move is only used in
autosave rotation it's simpler to change autosave rotation and remove
Move().

Now oldest autosaves (with lowest timestamp) will be removed in rotation.
2016-06-09 19:30:08 +02:00
Krzysztof Dermont 2168b57cac Remove part of boost::filesystem usage. 2016-06-09 19:30:08 +02:00
melex750 37ab015c8d Fix conversion to string with = operator 2016-05-29 06:55:28 -04:00
melex750 6db2832577 Fix conversion to string with + operator 2016-05-29 06:45:08 -04:00
melex750 0165e8f348 Fix and document TypeCompatible 2016-05-29 06:40:42 -04:00
krzys-h b56cd11c98 Added C++ operator overloads to CBotVar 2016-05-29 00:06:34 +02:00
krzys-h 7b32f6388f Enabled fixed test 2016-05-28 23:33:49 +02:00
krzys-h df111dbf98 Refactored CBotVar to templates 2016-05-28 23:28:12 +02:00
krzys-h 0e101debe0 Removed CAM_TYPE_INFO 2016-05-28 18:52:30 +02:00
krzys-h 646e5104f6 Some CCamera cleanup and docs 2016-05-28 18:44:38 +02:00
krzys-h bef27c3b36 Removed unused parameter from CEngine::SetViewParams 2016-05-28 16:48:36 +02:00
krzys-h d80fa387b9 Fixed some particle crashes after 99a831a03b 2016-05-28 16:16:48 +02:00
krzys-h 89b495c667 Cleaned up whitespace in translation strings 2016-05-28 16:03:02 +02:00
krzys-h 2dd7ba7e9b Added camera keybindings (#653) 2016-05-28 15:41:01 +02:00
krzys-h ebc2e6e26c Added camera joystick bindings (#653) 2016-05-28 13:50:41 +02:00
krzys-h 942f746a21 Removed CAM_TYPE_DIALOG 2016-05-28 12:50:32 +02:00
krzys-h 9feea63086 Jenkinsfile: change RPATH to current directory 2016-05-28 11:09:12 +02:00
krzys-h 2bebd0e87f Jenkinsfile: don't add runtime information on install in linux builds 2016-05-28 10:46:26 +02:00
krzys-h aa159bc9b0 Don't scale mouse cursor with resolution 2016-05-28 00:43:14 +02:00
krzys-h 99a831a03b Fixed CParticle::CheckChannel "errors"
Not really errors, but I fixed them anyway
2016-05-28 00:26:56 +02:00
krzys-h 5ab99429d4 Fixed FIX camera up/down movement 2016-05-28 00:00:08 +02:00
krzys-h 250047579f Allow using custom paths for win/lost scenes 2016-05-27 23:37:36 +02:00
krzys-h bd72086704 Unified all camera inputs
Until now each camera type had separate code for handling camera input, and some new features were missing in some of them.

The camera controls are as follows:
* RMB+mouse and numpad keys - horizontal/vertical rotation
* mouse wheel and +/- keys - zoom (in free camera - move eye up/down)
* CTRL or MMB + horizontal controls - pan left/right
* CTRL or MMB + zoom controls - move lookat up/down (free camera only)
2016-05-27 22:38:44 +02:00
krzys-h 261b26c8e9 Added Jenkinsfile 2016-05-27 18:30:56 +02:00
krzys-h 620620fa61 Reenabled working tests after fc7e621471 2016-05-27 11:45:02 +02:00
krzys_h fc7e621471 Merge pull request #781 from melex750/dev
Fix "this" bug - #256 & #436
2016-05-27 11:37:03 +02:00
melex750 6491ce0aa5 Fix passing "this" as an argument to a method 2016-05-24 10:30:20 -04:00
melex750 c19f97bc24 Fix RestoreState to assign IDs to instance vars 2016-05-24 10:09:44 -04:00
krzys-h cdd719cc47 Made clipping distance settings apply immediately 2016-05-21 19:05:18 +02:00
krzys-h 59c106f7a7 Fixed pause blur image not updating correctly on resolution change 2016-05-21 19:03:53 +02:00
Tomasz Kapuściński 213fd6b203 Added blur effect when the game is paused (issue #656)
Might be unstable, needs more testing. To enable, add PauseBlur=1 to [Experimental] section in colobot.ini
2016-05-21 14:27:35 +02:00
Tomasz Kapuściński 8922bb5e84 Renamed CGLDevice to CGL14Device 2016-05-11 14:50:18 +02:00
Tomasz Kapuściński ebca89d920 Removed texture coordinate generation
This feature was only needed by GL14 device to implement shadow mapping and is not supported by shader-based devices. Shadow mapping has been rewritten, so this feature is no longer needed.
2016-05-11 13:47:08 +02:00
Mateusz Przybył 734e6e97c0 Group source files for IDE projects in CMake
Merge pull request #773 from MrSimbax/msvc-project-org-cmake
2016-05-02 12:14:18 +02:00
tomangelo2 9870cfe8a8 Clamp FogStart value to 0 if negative
Should fix issue #766
2016-05-02 01:27:07 +02:00
krzys-h c00a7fd132 Do not zoom while scrolling lists, closes #769 2016-04-22 19:20:31 +02:00
krzys-h 7c551dc39d Added unit tests for #768 2016-04-19 21:09:41 +02:00
krzys_h 54a34a9b22 Merge pull request #768 from melex750/dev
Fix function and method overloading
2016-04-19 21:07:56 +02:00
melex750 e7942962d3 Fix checking parameters in CBotFunction 2016-04-19 10:36:06 -04:00
krzys-h 952a5423fd Fixed non-power-of-2 images in SatCom (closes #634); fixed not unloading textures on SatCom close 2016-04-10 13:53:34 +02:00
krzys-h dd8a324f9b Fixed crash when loading level with incorrect object type 2016-04-10 13:27:56 +02:00
krzys-h d3f808f66d Merge branch 'dev-savegame' into dev 2016-04-10 13:16:10 +02:00
krzys-h 4de9d25f04 Man, those compile errors... 2016-04-09 18:58:34 +02:00
krzys-h 32af7f45df Fixed missing #includes 2016-04-09 18:52:15 +02:00
krzys-h e75ed79fb5 Updated data submodule 2016-04-09 18:47:26 +02:00
krzys-h 04d7c343ef Removed misc.cpp / misc.h 2016-04-09 18:46:12 +02:00
krzys-h 139592bc00 Proper l10n for date/time 2016-04-09 18:23:57 +02:00
krzys-h 14e2910f83 Proper plural form translations for ObligatoryToken 2016-04-09 16:28:11 +02:00
krzys-h bd9184bd92 Refactored part of CScript to std::string 2016-04-08 22:27:42 +02:00
krzys-h 7f38aca766 Improvements to ObligatoryToken/ProhibitedToken
Now you can specify exactly how many times given instruction can occur
2016-04-08 22:15:58 +02:00
krzys-h 3e4fbe93a6 This time really fixed compile errors 2016-04-08 21:22:00 +02:00
krzys-h ed58e7e012 Fix compile warning 2016-04-08 21:16:03 +02:00
krzys-h 4c8da2c503 LevelController improvements; minor EndMissionTake cleanup
* using LevelController script in the level doesn't forcefully disable EndMissionTake and AudioChange anymore
* cleaned up some code related to processing EndMissionTake commands
2016-04-08 20:56:09 +02:00
krzys-h ae4e875729 Do not store exact object part positions
This seems to be unnecessary, as the animation update code should set those on its own. Needs some more testing though.
2016-04-08 18:28:35 +02:00
Piotr Dziwinski c6c01c332f Fix displaying of text highlights (#738) 2016-04-08 21:24:14 +12:00
krzys-h efc5431da2 Enabled ArraysInClasses test after 1941020993 2016-04-07 21:28:16 +02:00
krzys_h 1941020993 Merge pull request #762 from melex750/dev
Fix initializing arrays in class definition
2016-04-07 21:27:19 +02:00
krzys-h ac950978a9 Fixed AlienWorm collisions (#740) 2016-04-07 20:30:25 +02:00
krzys-h 0d12dedd90 Fixed failed assertion when non-damageable objects get fall damage (closes #764) 2016-04-07 20:21:35 +02:00
Piotr Dziwinski 71a77c77f6 Hack to finally fix #738
Text rendering is now done in window coordinates corresponding to window
pixels to avoid floating-point rounding errors that show up as rendering
artifacts
2016-04-06 23:08:50 +12:00
melex750 748f0034bd Fix array in a class not working with sizeof()...
...when no assignment is made in the definition.

It should pass this unit test now:
TEST_F(CBotUT, DISABLED_ArraysInClasses)
2016-04-05 15:02:41 -04:00
melex750 61440392d2 Fix initializing static array in class definition
issue #32
2016-04-05 14:00:15 -04:00
krzys-h c94ebb45e7 Moved pathman from common/ to app/ 2016-04-04 22:28:08 +02:00
krzys-h 09a586936b Updated data submodule 2016-04-03 22:23:12 +02:00
krzys-h 059a546689 Reenabled unit tests that started working after 14721001e5 2016-04-03 21:09:41 +02:00
krzys-h 14721001e5 Merged PR #737: Fix for various issues with initializing variables in CBOT 2016-04-03 21:08:52 +02:00
krzys-h 15702ec856 Fixed indentation 2016-04-03 20:29:55 +02:00
krzys-h 6216daedb3 Merge part of PR #756 2016-04-03 20:17:23 +02:00
KarolTrzeszczkowski 1960b373f1 Solves #700
It turns out, that tower is not over powered in code battle mode. It never hits flying enemy robot.
2016-04-03 13:31:08 +02:00
krzys-h c0780f938e One more code style fix 2016-04-03 13:19:51 +02:00
krzys-h 98dd9f90c8 Fixed code style warnings 2016-04-03 13:06:55 +02:00
Piotr Dziwinski 9639dc5f96 Fix typo 2016-04-03 22:25:59 +12:00
Piotr Dziwinski 72f966b118 Fix for #738
Add one-pixel boundary and fix texture coordinates for font characters
This should finally fix the issue of pixelated text
2016-04-03 21:40:33 +12:00
Piotr Dziwinski 3a3653d47e Add warning messages if tool programs are not found 2016-04-03 15:43:34 +12:00
Piotr Dziwinski 89389e82e8 Fix desktop SVG icon not resizing properly
Workaround for librsvg bug
2016-04-03 15:42:41 +12:00
Piotr Dziwinski b5438c3ae4 Fix CMake warning when compiling on OSX 2016-04-03 11:34:35 +12:00
krzys-h 02633e32c3 Merge branch 'master' into dev 2016-04-02 23:55:32 +02:00
krzys-h e77f9dbd36 Bump version to 0.1.7b 2016-04-02 23:53:07 +02:00
krzys-h 37d72351be Fixed log file creation crash (#755) 2016-04-02 23:53:07 +02:00
Smok94 6afdb7b6c8 First person camera unlocked for Me and Tech
*unlocked camaera button for Me and Tech
*unlocked first ferson view for Me and Tech
*Me and Tech have no "camera view" effect like robots in first person
mode

#156
2016-04-02 15:56:27 +02:00
Smok94 831276f378 Appearance customization face butons fix
*face buttons 2 and 4 swaped.
*default hair colors now fit to buttons look
*changing face changes hair color do default

Fixes two first issues mentioned in the #724
2016-04-02 13:13:42 +02:00
krzys-h 39b364fa77 Fixed compilation with disabled sound support, closes #748 2016-03-30 22:22:22 +02:00
krzys_h d84304cba5 Merge pull request #751 from OdyX/018-minor-fixes
Fix spelling error, and add Keywords to the desktop file
2016-03-30 14:00:45 +02:00
Didier Raboud 761c85468f Add Keywords key in desktop file
See:
- https://wiki.gnome.org/Initiatives/GnomeGoals/DesktopFileKeywords
- https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
2016-03-30 13:51:42 +02:00
Didier Raboud a06035ecb8 Fix occured/occurred spelling error 2016-03-30 13:40:26 +02:00
krzys_h ef0147eb37 Merge pull request #750 from Erihel/dev
Deactive pause before jumping to next visit
2016-03-29 22:33:13 +02:00
Krzysztof Dermont 8ccad5b954 Deactive pause before jumping to next visit
When pause was active setting new pause resulted in strange behavior.

This should fix issue #736.
2016-03-29 22:32:44 +02:00
krzys_h 7e1b11276c Merge pull request #749 from Erihel/dev
Change SatCom button size in main menu
2016-03-29 21:43:42 +02:00
Krzysztof Dermont 2ea453f484 Change SatCom button size in main menu
Change button size as proposed in issue #722
2016-03-29 21:36:33 +02:00
krzys-h 64fef98bd7 Merge branch 'dev-0.1.8' into dev 2016-03-29 16:16:20 +02:00
krzys-h 1c5f47703b Post-release 0.1.7-alpha 2016-03-29 16:08:20 +02:00
krzys-h 427bbfa630 Changed CParticle::CheckChannel log message 2016-03-28 23:04:24 +02:00
krzys-h e24d77bde8 goto() bitmap debugger 2016-03-28 21:42:25 +02:00
krzys-h d38ddcbc41 goto() path debugger 2016-03-28 20:25:07 +02:00
krzys-h e4f9360e63 Resources debug mode 2016-03-28 17:58:31 +02:00
krzys-h 4af02c86f8 Debug menu 2016-03-28 17:58:31 +02:00
krzys-h 45c93f58ec Fixed Houston lights when object is rotated 2016-03-27 18:54:56 +02:00
krzys-h 7fe65067ee Fixed exit after single mission mode 2016-03-27 13:46:48 +02:00
krzys-h d2ac1afcf0 Changed reference colors using when recoloring textures to constants 2016-03-27 13:34:26 +02:00
krzys-h adf20f58d4 Removed unused members of CNullDevice 2016-03-26 19:50:53 +01:00
krzys-h 5de577400b Refactor CRobotMain::ExecuteCmd() to std::string 2016-03-26 19:06:07 +01:00
krzys-h 6585ee9ae8 Refactor some references to CRobotMain from CEngine 2016-03-26 18:55:39 +01:00
krzys-h 640c0297ef Replaced CConfigFile::GetInstancePointer() with GetConfigFile() 2016-03-26 18:34:26 +01:00
melex750 02133d0bd4 Fix method overloading 2016-03-21 07:56:52 -04:00
melex750 8b7410f803 Fix class.arrays using size of one before comma 2016-03-21 06:11:55 -04:00
melex750 6be1f56288 Add error code no expression, remove some bad code 2016-03-20 20:55:22 -04:00
melex750 5b3da83715 Fix inline declaration of an array of string 2016-03-20 13:27:02 -04:00
melex750 707ef97626 Fix syntax+type checking, base types+CBotDefArray 2016-03-20 07:54:41 -04:00
melex750 accfc93573 Add syntax and type checking for class member vars 2016-03-20 07:50:42 -04:00
melex750 4a29e8406d Fix syntax and type checking for CBotListArray 2016-03-20 07:48:20 -04:00
866 changed files with 57535 additions and 71555 deletions

211
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,211 @@
name: Build
on: [push, pull_request]
jobs:
build-linux:
runs-on: ${{ matrix.host_os }}
container: ${{ matrix.container }}
strategy:
matrix:
target_os: [linux]
host_os: [ubuntu-20.04]
container: ['']
fail-fast: false
steps:
- name: Install Colobot dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet libglm-dev libmpg123-dev
if: matrix.container == ''
- uses: actions/checkout@v3
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Linux)
run: cmake --preset Linux-CI
if: matrix.target_os == 'linux'
- name: Build
run: cmake --build --preset Linux-CI
- name: Install
run: cmake --build --preset Linux-CI --target install
- name: Patch library path
run: patchelf --set-rpath '.' install/colobot
if: matrix.target_os == 'linux'
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: ${{matrix.target_os}}-debug
path: install
if: matrix.host_os == 'ubuntu-20.04'
- name: Create AppImage
working-directory: build
run: |
# Download app image tool
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
./linuxdeploy-x86_64.AppImage --appimage-extract
# Create AppImage
NO_STRIP=1 ./squashfs-root/AppRun -e colobot --output appimage --appdir colobot.AppDir -d desktop/colobot.desktop -i ../desktop/colobot.svg
chmod +x Colobot-x86_64.AppImage
# Prepare folder for zip
mkdir -p appimage
cp -rp ../install/data appimage/data
cp -rp ../install/lang appimage/lang
cp -p Colobot-x86_64.AppImage appimage/colobot
if: matrix.target_os == 'linux'
- name: Upload AppImage
uses: actions/upload-artifact@v3
with:
name: ${{matrix.target_os}}-debug-AppImage
path: build/appimage
if: matrix.target_os == 'linux' && matrix.host_os == 'ubuntu-20.04'
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'linux'
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
if: matrix.target_os == 'linux'
build-macos:
runs-on: ${{ matrix.host_os }}
container: ${{ matrix.container }}
strategy:
matrix:
target_os: [macos]
host_os: [macos-11, macos-12]
container: ['']
fail-fast: false
steps:
- name: Install Colobot dependencies
run: brew install cmake sdl2 sdl2_image sdl2_ttf glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet glm
if: matrix.container == ''
- uses: actions/checkout@v3
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Mac)
run: cmake --preset MacOS-CI
if: matrix.target_os == 'macos'
- name: Build
run: cmake --build --preset MacOS-CI
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'macos'
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
if: matrix.target_os == 'macos'
build-windows:
runs-on: windows-2019
strategy:
matrix:
include:
- arch: amd64
vcpkg_triplet: 'x64-windows-static'
- arch: x86
vcpkg_triplet: 'x86-windows-static'
steps:
- uses: actions/checkout@v3
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Setup VS Environment
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: ${{ matrix.arch }}
- name: Install Colobot dependencies
uses: lukka/run-vcpkg@v7
with:
setupOnly: true
vcpkgGitCommitId: 'f6a5d4e8eb7476b8d7fc12a56dff300c1c986131'
vcpkgTriplet: ${{ matrix.vcpkg_triplet }}
# SHA-256 hash of the vcpkg.json file, recalculated automatically when it changes
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
- name: Install external tools
working-directory: ${{ github.workspace }}
run: |
echo "Downloading gettext..."
(New-Object System.Net.WebClient).DownloadFile("https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.20.2-v1.16/gettext0.20.2-iconv1.16-static-64.zip", "gettext.zip");
echo "Unpacking gettext..."
7z x -ogettext gettext.zip;
echo "Adding gettext to PATH..."
echo "${{ github.workspace }}\gettext\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "Downloading xmlstarlet..."
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/xmlstar/xmlstarlet/1.6.1/xmlstarlet-1.6.1-win32.zip", "xmlstarlet.zip");
echo "Unpacking xmlstarlet..."
7z x -oxmlstarlet xmlstarlet.zip;
echo "Renaming xml.exe to xmlstarlet.exe"
Rename-Item -Path "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1\xml.exe" -NewName "xmlstarlet.exe"
echo "Adding xmlstarlet to PATH..."
echo "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "Downloading rsvg-convert..."
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/tumagcc/rsvg-convert-2.40.20.7z", "rsvg-convert.zip");
echo "Unpacking xmlstarlet..."
7z x -orsvg-convert rsvg-convert.zip;
echo "Adding rsvg-convert to PATH..."
echo "${{ github.workspace }}\rsvg-convert" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Windows)
run: cmake --preset Windows-CI -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake
- name: Build
run: |
$nproc = (Get-CIMInstance -Class 'CIM_Processor').NumberOfLogicalProcessors
cmake --build --preset Windows-CI -j $nproc
shell: pwsh
- name: Install
run: cmake --build --preset Windows-CI --target install
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: windows-msvc-debug-${{ matrix.arch }}
path: install
- name: Run tests
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: 'Test results (windows, MSVC, ${{ matrix.arch }})'
path: build/gtestresults.xml
doc:
runs-on: ubuntu-latest
steps:
- name: Install Colobot dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet doxygen graphviz libglm-dev libmpg123-dev
- uses: actions/checkout@v3
- name: Create build directory
run: cmake -E make_directory build
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Run CMake
working-directory: build
run: cmake ..
- name: Build docs
working-directory: build
run: make doc
- name: Upload docs
uses: actions/upload-artifact@v3
with:
name: doc
path: build/doc

21
.github/workflows/verify-pr-target.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Verify pull request target
on: [pull_request_target]
jobs:
check_pr_target:
runs-on: ubuntu-latest
steps:
- name: Send comment if wrong pull request target
if: github.base_ref == 'master'
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.number }}
body: |
Hey! This pull request targets the `master` branch. You should probably target `dev` instead. Make sure to read the [contributing guidelines](https://github.com/colobot/colobot/blob/master/CONTRIBUTING.md#submitting-pull-requests) and [edit the target branch if necessary](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-base-branch-of-a-pull-request).
- name: Wrong pull request target
if: github.base_ref == 'master'
run: echo "This pull request targets the master branch. Please edit the pull request to target dev." && exit 1
- name: Correct pull request target
if: github.base_ref != 'master'
run: echo "This pull request targets the correct branch." && exit 0

19
.gitignore vendored
View File

@ -11,11 +11,12 @@ Makefile
/src/libcolobotbase.a
# Ignore the generated documentation
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
/doc
/Doxyfile
# Ignore targets
/colobot
/src/CBot/libCBot.so
# Ignore local data
@ -23,7 +24,7 @@ Makefile
/saves
# Standard build directory
/build
/build*
# Ignore KDevelop files
.kdev4
@ -35,3 +36,17 @@ Makefile
# Ignore QtCreator temp files
CMakeLists.txt.user
CMakeLists.txt.user.*
# Ignore Visual Studio Code files
/.vscode
# Ignore CLion files
/.idea
# Ignore Visual Studio files
/CMakeSettings.json
/.vs
/out
# Ignore CMakeUserPresets.json
CMakeUserPresets.json

11
.gitmodules vendored
View File

@ -1,3 +1,12 @@
[submodule "data"]
path = data
url = git://github.com/colobot/colobot-data.git
url = https://github.com/colobot/colobot-data.git
branch = .
update = rebase
[submodule "lib/googletest"]
path = lib/googletest
url = https://github.com/google/googletest.git
ignore = all
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json

175
CBot/CMakeLists.txt Normal file
View File

@ -0,0 +1,175 @@
if(CBOT_STATIC)
add_library(CBot STATIC)
else()
add_library(CBot SHARED)
install(TARGETS CBot
LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
endif()
target_sources(CBot PRIVATE
src/CBot/CBot.h
src/CBot/CBotCStack.cpp
src/CBot/CBotCStack.h
src/CBot/CBotClass.cpp
src/CBot/CBotClass.h
src/CBot/CBotDebug.cpp
src/CBot/CBotDebug.h
src/CBot/CBotDefParam.cpp
src/CBot/CBotDefParam.h
src/CBot/CBotDefines.h
src/CBot/CBotEnums.h
src/CBot/CBotExternalCall.cpp
src/CBot/CBotExternalCall.h
src/CBot/CBotFileUtils.cpp
src/CBot/CBotFileUtils.h
src/CBot/CBotInstr/CBotBlock.cpp
src/CBot/CBotInstr/CBotBlock.h
src/CBot/CBotInstr/CBotBoolExpr.cpp
src/CBot/CBotInstr/CBotBoolExpr.h
src/CBot/CBotInstr/CBotBreak.cpp
src/CBot/CBotInstr/CBotBreak.h
src/CBot/CBotInstr/CBotCase.cpp
src/CBot/CBotInstr/CBotCase.h
src/CBot/CBotInstr/CBotCatch.cpp
src/CBot/CBotInstr/CBotCatch.h
src/CBot/CBotInstr/CBotCondition.cpp
src/CBot/CBotInstr/CBotCondition.h
src/CBot/CBotInstr/CBotDefArray.cpp
src/CBot/CBotInstr/CBotDefArray.h
src/CBot/CBotInstr/CBotDefBoolean.cpp
src/CBot/CBotInstr/CBotDefBoolean.h
src/CBot/CBotInstr/CBotDefClass.cpp
src/CBot/CBotInstr/CBotDefClass.h
src/CBot/CBotInstr/CBotDefFloat.cpp
src/CBot/CBotInstr/CBotDefFloat.h
src/CBot/CBotInstr/CBotDefInt.cpp
src/CBot/CBotInstr/CBotDefInt.h
src/CBot/CBotInstr/CBotDefString.cpp
src/CBot/CBotInstr/CBotDefString.h
src/CBot/CBotInstr/CBotDo.cpp
src/CBot/CBotInstr/CBotDo.h
src/CBot/CBotInstr/CBotEmpty.cpp
src/CBot/CBotInstr/CBotEmpty.h
src/CBot/CBotInstr/CBotExprLitBool.cpp
src/CBot/CBotInstr/CBotExprLitBool.h
src/CBot/CBotInstr/CBotExprLitChar.cpp
src/CBot/CBotInstr/CBotExprLitChar.h
src/CBot/CBotInstr/CBotExprLitNan.cpp
src/CBot/CBotInstr/CBotExprLitNan.h
src/CBot/CBotInstr/CBotExprLitNull.cpp
src/CBot/CBotInstr/CBotExprLitNull.h
src/CBot/CBotInstr/CBotExprLitNum.cpp
src/CBot/CBotInstr/CBotExprLitNum.h
src/CBot/CBotInstr/CBotExprLitString.cpp
src/CBot/CBotInstr/CBotExprLitString.h
src/CBot/CBotInstr/CBotExprRetVar.cpp
src/CBot/CBotInstr/CBotExprRetVar.h
src/CBot/CBotInstr/CBotExprUnaire.cpp
src/CBot/CBotInstr/CBotExprUnaire.h
src/CBot/CBotInstr/CBotExprVar.cpp
src/CBot/CBotInstr/CBotExprVar.h
src/CBot/CBotInstr/CBotExpression.cpp
src/CBot/CBotInstr/CBotExpression.h
src/CBot/CBotInstr/CBotFieldExpr.cpp
src/CBot/CBotInstr/CBotFieldExpr.h
src/CBot/CBotInstr/CBotFor.cpp
src/CBot/CBotInstr/CBotFor.h
src/CBot/CBotInstr/CBotFunction.cpp
src/CBot/CBotInstr/CBotFunction.h
src/CBot/CBotInstr/CBotIf.cpp
src/CBot/CBotInstr/CBotIf.h
src/CBot/CBotInstr/CBotIndexExpr.cpp
src/CBot/CBotInstr/CBotIndexExpr.h
src/CBot/CBotInstr/CBotInstr.cpp
src/CBot/CBotInstr/CBotInstr.h
src/CBot/CBotInstr/CBotInstrCall.cpp
src/CBot/CBotInstr/CBotInstrCall.h
src/CBot/CBotInstr/CBotInstrMethode.cpp
src/CBot/CBotInstr/CBotInstrMethode.h
src/CBot/CBotInstr/CBotInstrUtils.cpp
src/CBot/CBotInstr/CBotInstrUtils.h
src/CBot/CBotInstr/CBotLeftExpr.cpp
src/CBot/CBotInstr/CBotLeftExpr.h
src/CBot/CBotInstr/CBotLeftExprVar.cpp
src/CBot/CBotInstr/CBotLeftExprVar.h
src/CBot/CBotInstr/CBotListArray.cpp
src/CBot/CBotInstr/CBotListArray.h
src/CBot/CBotInstr/CBotListExpression.cpp
src/CBot/CBotInstr/CBotListExpression.h
src/CBot/CBotInstr/CBotListInstr.cpp
src/CBot/CBotInstr/CBotListInstr.h
src/CBot/CBotInstr/CBotLogicExpr.cpp
src/CBot/CBotInstr/CBotLogicExpr.h
src/CBot/CBotInstr/CBotNew.cpp
src/CBot/CBotInstr/CBotNew.h
src/CBot/CBotInstr/CBotParExpr.cpp
src/CBot/CBotInstr/CBotParExpr.h
src/CBot/CBotInstr/CBotPostIncExpr.cpp
src/CBot/CBotInstr/CBotPostIncExpr.h
src/CBot/CBotInstr/CBotPreIncExpr.cpp
src/CBot/CBotInstr/CBotPreIncExpr.h
src/CBot/CBotInstr/CBotRepeat.cpp
src/CBot/CBotInstr/CBotRepeat.h
src/CBot/CBotInstr/CBotReturn.cpp
src/CBot/CBotInstr/CBotReturn.h
src/CBot/CBotInstr/CBotSwitch.cpp
src/CBot/CBotInstr/CBotSwitch.h
src/CBot/CBotInstr/CBotThrow.cpp
src/CBot/CBotInstr/CBotThrow.h
src/CBot/CBotInstr/CBotTry.cpp
src/CBot/CBotInstr/CBotTry.h
src/CBot/CBotInstr/CBotTwoOpExpr.cpp
src/CBot/CBotInstr/CBotTwoOpExpr.h
src/CBot/CBotInstr/CBotWhile.cpp
src/CBot/CBotInstr/CBotWhile.h
src/CBot/CBotProgram.cpp
src/CBot/CBotProgram.h
src/CBot/CBotStack.cpp
src/CBot/CBotStack.h
src/CBot/CBotToken.cpp
src/CBot/CBotToken.h
src/CBot/CBotTypResult.cpp
src/CBot/CBotTypResult.h
src/CBot/CBotUtils.cpp
src/CBot/CBotUtils.h
src/CBot/CBotVar/CBotVar.cpp
src/CBot/CBotVar/CBotVar.h
src/CBot/CBotVar/CBotVarValue.h
src/CBot/CBotVar/CBotVarArray.cpp
src/CBot/CBotVar/CBotVarArray.h
src/CBot/CBotVar/CBotVarBoolean.cpp
src/CBot/CBotVar/CBotVarBoolean.h
src/CBot/CBotVar/CBotVarByte.h
src/CBot/CBotVar/CBotVarChar.h
src/CBot/CBotVar/CBotVarClass.cpp
src/CBot/CBotVar/CBotVarClass.h
src/CBot/CBotVar/CBotVarDouble.h
src/CBot/CBotVar/CBotVarFloat.cpp
src/CBot/CBotVar/CBotVarFloat.h
src/CBot/CBotVar/CBotVarInt.cpp
src/CBot/CBotVar/CBotVarInt.h
src/CBot/CBotVar/CBotVarLong.h
src/CBot/CBotVar/CBotVarPointer.cpp
src/CBot/CBotVar/CBotVarPointer.h
src/CBot/CBotVar/CBotVarShort.h
src/CBot/CBotVar/CBotVarString.cpp
src/CBot/CBotVar/CBotVarString.h
src/CBot/stdlib/Compilation.cpp
src/CBot/stdlib/Compilation.h
src/CBot/stdlib/FileFunctions.cpp
src/CBot/stdlib/MathFunctions.cpp
src/CBot/stdlib/StringFunctions.cpp
src/CBot/stdlib/stdlib.h
src/CBot/stdlib/stdlib_public.h
)
target_include_directories(CBot PUBLIC src)
target_link_libraries(CBot PRIVATE
Colobot-Common
)
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("src/CBot" CBot)
endif()

View File

@ -1,5 +1,5 @@
/**
* \dir src/CBot
* \dir CBot
* \brief CBot library
*/
@ -7,3 +7,4 @@
* \namespace CBot
* \brief CBot engine
*/

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -20,6 +20,7 @@
#include "CBot/CBotCStack.h"
#include "CBot/CBotClass.h"
#include "CBot/CBotToken.h"
#include "CBot/CBotExternalCall.h"
@ -30,107 +31,100 @@
namespace CBot
{
////////////////////////////////////////////////////////////////////////////////
CBotProgram* CBotCStack::m_prog = nullptr; // init the static variable
CBotError CBotCStack::m_error = CBotNoErr;
int CBotCStack::m_end = 0;
CBotTypResult CBotCStack::m_retTyp = CBotTypResult(0);
struct CBotCStack::Data
{
//! The program currently being compiled
CBotProgram* prog = nullptr;
//! The current error state of the compile stack
CBotError error = CBotNoErr;
int errEnd = 0;
//! The return type of the function currently being compiled
CBotTypResult retTyp = CBotTypResult(CBotTypVoid);
};
////////////////////////////////////////////////////////////////////////////////
CBotCStack::CBotCStack(CBotCStack* ppapa)
{
m_next = nullptr;
m_prev = ppapa;
if (ppapa == nullptr)
{
m_error = CBotNoErr;
m_start = 0;
m_end = 0;
m_data = new CBotCStack::Data;
m_errStart = 0;
m_bBlock = true;
}
else
{
m_start = ppapa->m_start;
m_data = ppapa->m_data;
m_errStart = ppapa->m_errStart;
m_bBlock = false;
}
m_listVar = nullptr;
m_var = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
CBotCStack::~CBotCStack()
{
if (m_next != nullptr) delete m_next;
if (m_prev != nullptr) m_prev->m_next = nullptr; // removes chain
delete m_var;
delete m_listVar;
if (m_prev == nullptr) delete m_data;
}
////////////////////////////////////////////////////////////////////////////////
CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
{
if (m_next != nullptr) return m_next; // include on an existing stack
if (m_next) return m_next.get(); // include on an existing stack
CBotCStack* p = new CBotCStack(this);
m_next = p; // channel element
p->m_bBlock = bBlock;
m_next.reset(new CBotCStack(this));
m_next->m_bBlock = bBlock;
if (pToken != nullptr) p->SetStartError(pToken->GetStart());
if (pToken != nullptr) m_next->SetStartError(pToken->GetStart());
return p;
return m_next.get();
}
void CBotCStack::DeleteNext()
{
m_next.reset();
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
{
if ( pfils == this ) return inst;
if (m_var != nullptr) delete m_var; // value replaced?
m_var = pfils->m_var; // result transmitted
pfils->m_var = nullptr; // not to destroy the variable
m_var = std::move(pfils->m_var); // result transmitted
if (m_error)
if (m_data->error != CBotNoErr)
{
m_start = pfils->m_start; // retrieves the position of the error
m_end = pfils->m_end;
m_errStart = pfils->m_errStart; // retrieves the position of the error
}
delete pfils;
m_next.reset();
return inst;
}
////////////////////////////////////////////////////////////////////////////////
CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
{
if (m_var != nullptr) delete m_var; // value replaced?
m_var = pfils->m_var; // result transmitted
pfils->m_var = nullptr; // not to destroy the variable
m_var = std::move(pfils->m_var); // result transmitted
if (m_error)
if (m_data->error != CBotNoErr)
{
m_start = pfils->m_start; // retrieves the position of the error
m_end = pfils->m_end;
m_errStart = pfils->m_errStart; // retrieves the position of the error
}
delete pfils;
m_next.reset();
return inst;
}
////////////////////////////////////////////////////////////////////////////////
CBotError CBotCStack::GetError(int& start, int& end)
{
start = m_start;
end = m_end;
return m_error;
start = m_errStart;
end = m_data->errEnd;
return m_data->error;
}
////////////////////////////////////////////////////////////////////////////////
CBotError CBotCStack::GetError()
{
return m_error;
return m_data->error;
}
////////////////////////////////////////////////////////////////////////////////
@ -170,18 +164,13 @@ void CBotCStack::SetType(CBotTypResult& type)
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
{
CBotCStack* p = this;
std::string name = pToken->GetString();
const auto& name = pToken->GetString();
while (p != nullptr)
{
CBotVar* pp = p->m_listVar;
while ( pp != nullptr)
if (p->m_bBlock) for (auto& var : p->m_listVar)
{
if (name == pp->GetName())
{
return pp;
}
pp = pp->m_next;
if (name == var->GetName()) return var.get();
}
p = p->m_prev;
}
@ -210,39 +199,39 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token)
////////////////////////////////////////////////////////////////////////////////
bool CBotCStack::IsOk()
{
return (m_error == 0);
return (m_data->error == CBotNoErr);
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetStartError( int pos )
{
if ( m_error != 0) return; // does not change existing error
m_start = pos;
if (m_data->error != CBotNoErr) return; // does not change existing error
m_errStart = pos;
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetError(CBotError n, int pos)
{
if ( n!= 0 && m_error != 0) return; // does not change existing error
m_error = n;
m_end = pos;
if (n != CBotNoErr && m_data->error != CBotNoErr) return; // does not change existing error
m_data->error = n;
m_data->errEnd = pos;
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetError(CBotError n, CBotToken* p)
{
if (m_error) return; // does not change existing error
m_error = n;
m_start = p->GetStart();
m_end = p->GetEnd();
if (m_data->error != CBotNoErr) return; // does not change existing error
m_data->error = n;
m_errStart = p->GetStart();
m_data->errEnd = p->GetEnd();
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::ResetError(CBotError n, int start, int end)
{
m_error = n;
m_start = start;
m_end = end;
m_data->error = n;
m_errStart = start;
m_data->errEnd = end;
}
////////////////////////////////////////////////////////////////////////////////
@ -260,48 +249,47 @@ bool CBotCStack::NextToken(CBotToken* &p)
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetProgram(CBotProgram* p)
{
m_prog = p;
m_data->prog = p;
}
////////////////////////////////////////////////////////////////////////////////
CBotProgram* CBotCStack::GetProgram()
{
return m_prog;
return m_data->prog;
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetRetType(CBotTypResult& type)
{
m_retTyp = type;
m_data->retTyp = type;
}
////////////////////////////////////////////////////////////////////////////////
CBotTypResult CBotCStack::GetRetType()
{
return m_retTyp;
return m_data->retTyp;
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetVar( CBotVar* var )
{
if (m_var) delete m_var; // replacement of a variable
m_var = var;
m_var.reset(var);
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::SetCopyVar( CBotVar* var )
{
if (m_var) delete m_var; // replacement of a variable
m_var.reset();
if ( var == nullptr ) return;
m_var = CBotVar::Create("", var->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
m_var.reset(CBotVar::Create("", var->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC)));
m_var->Copy( var );
}
////////////////////////////////////////////////////////////////////////////////
CBotVar* CBotCStack::GetVar()
{
return m_var;
return m_var.get();
}
////////////////////////////////////////////////////////////////////////////////
@ -309,34 +297,70 @@ void CBotCStack::AddVar(CBotVar* pVar)
{
CBotCStack* p = this;
// returns to the father element
// find the level of the current block
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
if ( p == nullptr ) return;
if (p == nullptr || pVar == nullptr) return;
CBotVar** pp = &p->m_listVar;
while ( *pp != nullptr ) pp = &(*pp)->m_next;
p->m_listVar.emplace_back(pVar);
}
*pp = pVar; // added after
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::CreateVarThis(CBotClass* pClass)
{
if ( pClass == nullptr ) return;
CBotVar* pThis = CBotVar::Create("this", CBotTypResult(CBotTypClass, pClass));
pThis->SetUniqNum(-2); // special ID for "this"
AddVar(pThis);
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::CreateVarSuper(CBotClass* pClass)
{
if ( pClass == nullptr ) return;
CBotVar* pSuper = CBotVar::Create("super", CBotTypResult(CBotTypClass, pClass));
pSuper->SetUniqNum(-3); // special ID for "super"
AddVar(pSuper);
}
////////////////////////////////////////////////////////////////////////////////
void CBotCStack::CreateMemberVars(CBotClass* pClass, bool setDefined)
{
while (pClass != nullptr)
{
CBotVar* pv = pClass->GetVar();
while (pv != nullptr)
{
CBotVar* pcopy = CBotVar::Create(pv);
CBotVar::InitType initType = CBotVar::InitType::UNDEF;
if (setDefined || pv->IsStatic())
initType = CBotVar::InitType::DEF;
pcopy->SetInit(initType);
pcopy->SetUniqNum(pv->GetUniqNum());
pcopy->SetPrivate(pv->GetPrivate());
AddVar(pcopy);
pv = pv->GetNext();
}
pClass = pClass->GetParent();
}
}
////////////////////////////////////////////////////////////////////////////////
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
{
CBotCStack* p = this;
std::string name = pToken->GetString();
const auto& name = pToken->GetString();
while (p != nullptr)
// find the level of the current block
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
if (p != nullptr) for (auto& var : p->m_listVar)
{
CBotVar* pp = p->m_listVar;
while ( pp != nullptr)
{
if (name == pp->GetName())
return true;
pp = pp->m_next;
}
if ( p->m_bBlock ) return false;
p = p->m_prev;
if (name == var->GetName()) return true;
}
return false;
}
@ -347,10 +371,10 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
nIdent = 0;
CBotTypResult val(-1);
val = m_prog->GetExternalCalls()->CompileCall(p, nullptr, ppVars, this);
val = GetProgram()->GetExternalCalls()->CompileCall(p, nullptr, ppVars, this);
if (val.GetType() < 0)
{
val = m_prog->GetFunctions()->CompileCall(p->GetString(), ppVars, nIdent);
val = CBotFunction::CompileCall(p->GetString(), ppVars, nIdent, GetProgram());
if ( val.GetType() < 0 )
{
// pVar = nullptr; // the error is not on a particular parameter
@ -363,28 +387,32 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
}
////////////////////////////////////////////////////////////////////////////////
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam, const std::string& className)
{
std::string name = pToken->GetString();
const auto& name = pToken->GetString();
if ( m_prog->GetExternalCalls()->CheckCall(name) ) return true;
if ( GetProgram()->GetExternalCalls()->CheckCall(name) ) return true;
CBotFunction* pp = m_prog->GetFunctions();
while ( pp != nullptr )
for (CBotFunction* pp : GetProgram()->GetFunctions())
{
if ( pToken->GetString() == pp->GetName() )
if ( name == pp->GetName() )
{
// ignore methods for a different class
if ( className != pp->GetClassName() )
continue;
// are parameters exactly the same?
if ( pp->CheckParam( pParam ) )
return true;
}
pp = pp->Next();
}
for (CBotFunction* pp : CBotFunction::m_publicFunctions)
{
if ( pToken->GetString() == pp->GetName() )
if ( name == pp->GetName() )
{
// ignore methods for a different class
if ( className != pp->GetClassName() )
continue;
// are parameters exactly the same?
if ( pp->CheckParam( pParam ) )
return true;
@ -394,4 +422,4 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
return false;
}
}
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -22,6 +22,9 @@
#include "CBot/CBotVar/CBotVar.h"
#include "CBot/CBotProgram.h"
#include <list>
#include <memory>
namespace CBot
{
@ -100,6 +103,25 @@ public:
*/
void AddVar(CBotVar* p);
/*!
* \brief Create 'this' as a local variable.
* \param pClass The current class referred to by 'this'
*/
void CreateVarThis(CBotClass* pClass);
/*!
* \brief Create 'super' as a local variable.
* \param pClass The parent class referred to by 'super'
*/
void CreateVarSuper(CBotClass* pClass);
/*!
* \brief Create member variables of the current class as local variables.
* \param pClass The current class.
* \param setDefined Whether to mark the variables as initialized.
*/
void CreateMemberVars(CBotClass* pClass, bool setDefined);
/*!
* \brief FindVar Finds a variable. Seeks a variable on the stack the token
* may be a result of TokenTypVar (object of a class) or a pointer in the
@ -138,6 +160,11 @@ public:
*/
CBotCStack* TokenStack(CBotToken* pToken = nullptr, bool bBlock = false);
/*!
* \brief Deletes all subsequent stack frames created by TokenStack.
*/
void DeleteNext();
/*!
* \brief Return Transmits the result upper.
* \param p
@ -235,11 +262,12 @@ public:
/*!
* \brief CheckCall Test if a procedure name is already defined somewhere.
* \param pToken
* \param pParam
* \param pToken Token representing the name of a function.
* \param pParam List of parameters.
* \param className Name of a class when checking for methods.
* \return
*/
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam, const std::string& className);
/*!
* \brief NextToken
@ -249,21 +277,20 @@ public:
bool NextToken(CBotToken* &p);
private:
CBotCStack* m_next;
std::unique_ptr<CBotCStack> m_next;
CBotCStack* m_prev;
static CBotError m_error;
static int m_end;
int m_start;
int m_errStart = 0;
struct Data;
CBotCStack::Data* m_data;
//! Result of the operations.
CBotVar* m_var;
std::unique_ptr<CBotVar> m_var;
//! Is part of a block (variables are local to this block).
bool m_bBlock;
CBotVar* m_listVar;
//! List of compiled functions.
static CBotProgram* m_prog;
static CBotTypResult m_retTyp;
std::list<std::unique_ptr<CBotVar>> m_listVar;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -19,8 +19,10 @@
#include "CBot/CBotClass.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotInstr/CBotNew.h"
#include "CBot/CBotInstr/CBotLeftExprVar.h"
#include "CBot/CBotInstr/CBotExprLitNull.h"
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
#include "CBot/CBotInstr/CBotFunction.h"
#include "CBot/CBotInstr/CBotExpression.h"
@ -32,9 +34,8 @@
#include "CBot/CBotExternalCall.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
#include "CBot/CBotDefParam.h"
#include "CBot/CBotUtils.h"
#include "CBot/CBotFileUtils.h"
#include "CBot/CBotCallMethode.h"
#include <algorithm>
@ -52,8 +53,7 @@ CBotClass::CBotClass(const std::string& name,
m_parent = parent;
m_name = name;
m_pVar = nullptr;
m_pCalls = nullptr;
m_pMethod = nullptr;
m_externalMethods = new CBotExternalCallList();
m_rUpdate = nullptr;
m_IsDef = true;
m_bIntrinsic= bIntrinsic;
@ -68,8 +68,7 @@ CBotClass::~CBotClass()
m_publicClasses.erase(this);
delete m_pVar;
delete m_pCalls;
delete m_pMethod;
delete m_externalMethods;
}
////////////////////////////////////////////////////////////////////////////////
@ -83,26 +82,24 @@ CBotClass* CBotClass::Create(const std::string& name,
////////////////////////////////////////////////////////////////////////////////
void CBotClass::ClearPublic()
{
m_publicClasses.clear();
while ( !m_publicClasses.empty() )
{
auto it = m_publicClasses.begin();
delete *it; // calling destructor removes the class from the list
}
}
////////////////////////////////////////////////////////////////////////////////
void CBotClass::Purge()
{
if ( this == nullptr ) return;
delete m_pVar;
m_pVar = nullptr;
delete m_pCalls;
m_pCalls = nullptr;
delete m_pMethod;
m_pMethod = nullptr;
m_externalMethods->Clear();
for (CBotFunction* f : m_pMethod) delete f;
m_pMethod.clear();
m_IsDef = false;
m_nbVar = m_parent == nullptr ? 0 : m_parent->m_nbVar;
m_next->Purge();
m_next = nullptr; // no longer belongs to this chain
}
////////////////////////////////////////////////////////////////////////////////
@ -194,7 +191,7 @@ bool CBotClass::AddItem(CBotVar* pVar)
}
////////////////////////////////////////////////////////////////////////////////
std::string CBotClass::GetName()
const std::string& CBotClass::GetName()
{
return m_name;
}
@ -202,7 +199,6 @@ std::string CBotClass::GetName()
////////////////////////////////////////////////////////////////////////////////
CBotClass* CBotClass::GetParent()
{
if ( this == nullptr ) return nullptr;
return m_parent;
}
@ -252,6 +248,19 @@ CBotVar* CBotClass::GetItemRef(int nIdent)
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::CheckVar(const std::string &name)
{
CBotVar* p = m_pVar;
while ( p != nullptr )
{
if ( p->GetName() == name ) return true;
p = p->GetNext();
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::IsIntrinsic()
{
@ -280,29 +289,7 @@ bool CBotClass::AddFunction(const std::string& name,
bool rExec(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
CBotTypResult rCompile(CBotVar* pThis, CBotVar*& pVar))
{
// stores pointers to the two functions
CBotCallMethode* p = m_pCalls;
CBotCallMethode* pp = nullptr;
while ( p != nullptr )
{
if ( name == p->m_name )
{
if ( pp == nullptr ) m_pCalls = p->m_next;
else pp->m_next = p->m_next;
delete p;
break;
}
pp = p;
p = p->m_next;
}
p = new CBotCallMethode(name, rExec, rCompile);
if (m_pCalls == nullptr) m_pCalls = p;
else m_pCalls->AddNext(p); // added to the list
return true;
return m_externalMethods->AddFunction(name, std::unique_ptr<CBotExternalCall>(new CBotExternalCallClass(rExec, rCompile)));
}
////////////////////////////////////////////////////////////////////////////////
@ -313,125 +300,133 @@ bool CBotClass::SetUpdateFunc(void rUpdate(CBotVar* thisVar, void* user))
}
////////////////////////////////////////////////////////////////////////////////
CBotTypResult CBotClass::CompileMethode(const std::string& name,
CBotTypResult CBotClass::CompileMethode(CBotToken* name,
CBotVar* pThis,
CBotVar** ppParams,
CBotCStack* pStack,
long& nIdent)
long &nIdent)
{
nIdent = 0; // forget the previous one if necessary
// find the methods declared by AddFunction
CBotTypResult r = m_pCalls->CompileCall(name, pThis, ppParams, pStack);
CBotTypResult r = m_externalMethods->CompileCall(name, pThis, ppParams, pStack);
if ( r.GetType() >= 0) return r;
// find the methods declared by user
r = m_pMethod->CompileCall(name, ppParams, nIdent);
r = CBotFunction::CompileMethodCall(name->GetString(), ppParams, nIdent, pStack, this);
if ( r.Eq(CBotErrUndefCall) && m_parent != nullptr )
return m_parent->m_pMethod->CompileCall(name, ppParams, nIdent);
return m_parent->CompileMethode(name, pThis, ppParams, pStack, nIdent);
return r;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::ExecuteMethode(long& nIdent,
const std::string& name,
CBotVar* pThis,
CBotVar** ppParams,
CBotVar*& pResult,
CBotTypResult pResultType,
CBotStack*& pStack,
CBotToken* pToken)
{
int ret = m_pCalls->DoCall(name, pThis, ppParams, pResult, pStack, pToken);
if (ret>=0) return ret;
int ret = m_externalMethods->DoCall(pToken, pThis, ppParams, pStack, pResultType);
if (ret >= 0) return ret;
ret = m_pMethod->DoCall(nIdent, name, pThis, ppParams, pStack, pToken, this);
ret = CBotFunction::DoCall(nIdent, pToken->GetString(), pThis, ppParams, pStack, pToken, this);
if (ret >= 0) return ret;
if (m_parent != nullptr)
{
ret = m_parent->m_pCalls->DoCall(name, pThis, ppParams, pResult, pStack, pToken);
if (ret >= 0) return ret;
ret = m_parent->m_pMethod->DoCall(nIdent, name, pThis, ppParams, pStack, pToken, m_parent);
ret = m_parent->ExecuteMethode(nIdent, pThis, ppParams, pResultType, pStack, pToken);
}
return ret;
}
////////////////////////////////////////////////////////////////////////////////
void CBotClass::RestoreMethode(long& nIdent,
const std::string& name,
CBotToken* name,
CBotVar* pThis,
CBotVar** ppParams,
CBotStack*& pStack)
{
m_pMethod->RestoreCall(nIdent, name, pThis, ppParams, pStack, this);
if (m_externalMethods->RestoreCall(name, pThis, ppParams, pStack))
return;
CBotClass* pClass = this;
while (pClass != nullptr)
{
bool ok = CBotFunction::RestoreCall(nIdent, name->GetString(), pThis, ppParams, pStack, pClass);
if (ok) return;
pClass = pClass->m_parent;
}
assert(false);
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::SaveStaticState(FILE* pf)
bool CBotClass::SaveStaticState(std::ostream &ostr)
{
if (!WriteWord( pf, CBOTVERSION*2)) return false;
if (!WriteLong(ostr, CBOTVERSION*2)) return false;
// saves the state of static variables in classes
for (CBotClass* p : m_publicClasses)
{
if (!WriteWord( pf, 1 )) return false;
if (!WriteWord(ostr, 1)) return false;
// save the name of the class
if (!WriteString( pf, p->GetName() )) return false;
if (!WriteString(ostr, p->GetName())) return false;
CBotVar* pv = p->GetVar();
while( pv != nullptr )
{
if ( pv->IsStatic() )
{
if (!WriteWord( pf, 1 )) return false;
if (!WriteString( pf, pv->GetName() )) return false;
if (!WriteWord(ostr, 1)) return false;
if (!WriteString(ostr, pv->GetName())) return false;
if ( !pv->Save0State(pf) ) return false; // common header
if ( !pv->Save1State(pf) ) return false; // saves as the child class
if ( !WriteWord( pf, 0 ) ) return false;
if (!pv->Save0State(ostr)) return false; // common header
if (!pv->Save1State(ostr)) return false; // saves as the child class
if (!WriteWord(ostr, 0)) return false;
}
pv = pv->GetNext();
}
if (!WriteWord( pf, 0 )) return false;
if (!WriteWord(ostr, 0)) return false;
}
if (!WriteWord( pf, 0 )) return false;
if (!WriteWord(ostr, 0)) return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::RestoreStaticState(FILE* pf)
bool CBotClass::RestoreStaticState(std::istream &istr)
{
std::string ClassName, VarName;
CBotClass* pClass;
unsigned short w;
if (!ReadWord( pf, w )) return false;
if ( w != CBOTVERSION*2 ) return false;
long version;
if (!ReadLong(istr, version)) return false;
if (version != CBOTVERSION*2) return false;
while (true)
{
if (!ReadWord( pf, w )) return false;
if (!ReadWord(istr, w)) return false;
if ( w == 0 ) return true;
if (!ReadString( pf, ClassName )) return false;
if (!ReadString(istr, ClassName)) return false;
pClass = Find(ClassName);
while (true)
{
if (!ReadWord( pf, w )) return false;
if (!ReadWord(istr, w)) return false;
if ( w == 0 ) break;
CBotVar* pVar = nullptr;
CBotVar* pv = nullptr;
if (!ReadString( pf, VarName )) return false;
if (!ReadString(istr, VarName)) return false;
if ( pClass != nullptr ) pVar = pClass->GetItem(VarName);
if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable
if (!CBotVar::RestoreState(istr, pv)) return false; // the temp variable
if ( pVar != nullptr ) pVar->Copy(pv);
delete pv;
@ -447,8 +442,7 @@ bool CBotClass::CheckCall(CBotProgram* program, CBotDefParam* pParam, CBotToken*
if ( program->GetExternalCalls()->CheckCall(name) ) return true;
CBotFunction* pp = m_pMethod;
while ( pp != nullptr )
for (CBotFunction* pp : m_pMethod)
{
if ( pToken->GetString() == pp->GetName() )
{
@ -456,7 +450,6 @@ bool CBotClass::CheckCall(CBotProgram* program, CBotDefParam* pParam, CBotToken*
if ( pp->CheckParam( pParam ) )
return true;
}
pp = pp->Next();
}
return false;
@ -475,49 +468,85 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
std::string name = p->GetString();
CBotClass* pOld = CBotClass::Find(name);
if ( pOld != nullptr && pOld->m_IsDef )
{
pStack->SetError( CBotErrRedefClass, p );
return nullptr;
}
// a name of the class is there?
if (IsOfType(p, TokenTypVar))
{
CBotClass* pOld = CBotClass::Find(name);
if ((pOld != nullptr && pOld->m_IsDef) || /* public class exists in different program */
pStack->GetProgram()->ClassExists(name)) /* class exists in this program */
{
pStack->SetError(CBotErrRedefClass, p->GetPrev());
return nullptr;
}
CBotClass* pPapa = nullptr;
if ( IsOfType( p, ID_EXTENDS ) )
{
std::string name = p->GetString();
pPapa = CBotClass::Find(name);
CBotToken* pp = p;
if (!IsOfType(p, TokenTypVar) || pPapa == nullptr )
{
pStack->SetError( CBotErrNotClass, p );
pStack->SetError(CBotErrNoClassName, pp);
return nullptr;
}
}
CBotClass* classe = (pOld == nullptr) ? new CBotClass(name, pPapa) : pOld;
classe->Purge(); // empty the old definitions // TODO: Doesn't this remove all classes of the current program?
classe->Purge(); // empty the old definitions
classe->m_IsDef = false; // current definition
classe->m_pOpenblk = p;
if ( !IsOfType( p, ID_OPBLK) )
{
pStack->SetError(CBotErrOpenBlock, p);
return nullptr;
}
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
int level = 1;
while (level > 0 && p != nullptr)
{
classe->CompileDefItem(p, pStack, false);
int type = p->GetType();
p = p->GetNext();
if (type == ID_OPBLK) level++;
if (type == ID_CLBLK) level--;
}
if (level > 0) pStack->SetError(CBotErrCloseBlock, classe->m_pOpenblk);
if (pStack->IsOk()) return classe;
}
else
pStack->SetError(CBotErrNoClassName, p);
pStack->SetError(CBotErrNoTerminator, p);
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
void CBotClass::DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pStack)
{
for (CBotClass* pClass : pClassList)
{
CBotClass* pParent = pClass->m_parent;
pClass->m_nbVar = (pParent == nullptr) ? 0 : pParent->m_nbVar;
CBotToken* p = pClass->m_pOpenblk->GetNext();
while (pStack->IsOk() && !IsOfType(p, ID_CLBLK))
{
pClass->CompileDefItem(p, pStack, false);
}
if (!pStack->IsOk()) return;
}
}
const std::list<CBotFunction*>& CBotClass::GetFunctions() const
{
return m_pMethod;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
@ -549,6 +578,9 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
while (pStack->IsOk())
{
CBotTypResult type2 = CBotTypResult(type); // reset type after comma
CBotToken* varToken = p;
std::string pp = p->GetString();
if ( IsOfType(p, ID_NOT) )
{
@ -557,115 +589,44 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if (IsOfType(p, TokenTypVar))
{
CBotInstr* limites = nullptr;
while ( IsOfType( p, ID_OPBRK ) ) // a table?
{
CBotInstr* i = nullptr;
if ( p->GetType() != ID_CLBRK )
i = CBotExpression::Compile( p, pStack ); // expression for the value
else
i = new CBotEmpty(); // special if not a formula
type = CBotTypResult(CBotTypArrayPointer, type);
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
{
pStack->SetError(CBotErrCloseIndex, p->GetStart());
return false;
}
/* CBotVar* pv = pStack->GetVar();
if ( pv->GetType()>= CBotTypBoolean )
{
pStack->SetError(CBotErrBadType1, p->GetStart());
return false;
}*/
if (limites == nullptr) limites = i;
else limites->AddNext3(i);
}
if ( p->GetType() == ID_OPENPAR )
{
if ( !bSecond )
{
p = pBase;
CBotFunction* f =
CBotFunction::Compile1(p, pStack, this);
CBotFunction* f = CBotFunction::Compile1(p, pStack, this);
if ( f == nullptr ) return false;
if (m_pMethod == nullptr) m_pMethod = f;
else m_pMethod->AddNext(f);
m_pMethod.push_back(f);
}
else
{
// return a method precompiled in pass 1
CBotFunction* pf = m_pMethod;
CBotFunction* prev = nullptr;
while ( pf != nullptr )
CBotCStack* pStk = pStack->TokenStack(nullptr, true);
CBotDefParam* params = CBotDefParam::Compile(p, pStk );
pStack->DeleteNext();
auto pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, &params](CBotFunction* x)
{
if (pf->GetName() == pp) break;
prev = pf;
pf = pf->Next();
}
return x->GetName() == pp && x->CheckParam( params );
});
assert(pfIter != m_pMethod.end());
CBotFunction* pf = *pfIter;
delete params;
bool bConstructor = (pp == GetName());
CBotCStack* pile = pStack->TokenStack(nullptr, true);
// make "this" known
CBotToken TokenThis(std::string("this"), std::string());
CBotVar* pThis = CBotVar::Create(TokenThis, CBotTypResult( CBotTypClass, this ) );
pThis->SetUniqNum(-2);
pile->AddVar(pThis);
if (m_parent)
{
// makes "super" known
CBotToken TokenSuper(std::string("super"), std::string());
CBotVar* pThis = CBotVar::Create(TokenSuper, CBotTypResult(CBotTypClass, m_parent) );
pThis->SetUniqNum(-3);
pile->AddVar(pThis);
}
// int num = 1;
CBotClass* my = this;
while (my != nullptr)
{
// places a copy of variables of a class (this) on a stack
CBotVar* pv = my->m_pVar;
while (pv != nullptr)
{
CBotVar* pcopy = CBotVar::Create(pv);
CBotVar::InitType initType = CBotVar::InitType::UNDEF;
if (!bConstructor || pv->IsStatic())
initType = CBotVar::InitType::DEF;
pcopy->SetInit(initType);
pcopy->SetUniqNum(pv->GetUniqNum());
pile->AddVar(pcopy);
pv = pv->GetNext();
}
my = my->m_parent;
}
// compiles a method
p = pBase;
CBotFunction* f =
CBotFunction::Compile(p, pile, nullptr/*, false*/);
CBotFunction::Compile(p, pile, pf/*, false*/);
if ( f != nullptr )
{
f->m_pProg = pStack->GetProgram();
f->m_bSynchro = bSynchro;
// replaces the element in the chain
f->m_next = pf->m_next;
pf->m_next = nullptr;
delete pf;
if (prev == nullptr) m_pMethod = f;
else prev->m_next = f;
}
pStack->Return(nullptr, pile);
pStack->DeleteNext();
}
return pStack->IsOk();
@ -678,25 +639,89 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
return false;
}
if (pp[0] == '~' || pp == GetName()) // bad variable name
{
pStack->SetError(CBotErrNoVar, varToken);
return false;
}
if (!bSecond && CheckVar(pp)) // variable already exists
{
pStack->SetError(CBotErrRedefVar, varToken);
return false;
}
CBotInstr* limites = nullptr;
while ( IsOfType( p, ID_OPBRK ) ) // an array
{
CBotInstr* i = nullptr;
pStack->SetStartError( p->GetStart() );
if ( p->GetType() != ID_CLBRK )
{
i = CBotExpression::Compile( p, pStack ); // expression for the value
if (i == nullptr || pStack->GetType() != CBotTypInt) // must be a number
{
pStack->SetError(CBotErrBadIndex, p->GetStart());
}
}
else
i = new CBotEmpty(); // special if not a formula
type2 = CBotTypResult(CBotTypArrayPointer, type2);
if (limites == nullptr) limites = i;
else limites->AddNext3(i);
if (pStack->IsOk() && IsOfType(p, ID_CLBRK)) continue;
pStack->SetError(CBotErrCloseIndex, p->GetStart());
delete limites;
return false;
}
CBotInstr* i = nullptr;
if ( IsOfType(p, ID_ASS ) )
{
if ( type.Eq(CBotTypArrayPointer) )
pStack->SetStartError(p->GetStart());
if ( IsOfType(p, ID_SEP) )
{
i = CBotListArray::Compile(p, pStack, type.GetTypElem());
pStack->SetError(CBotErrNoExpression, p->GetStart());
return false;
}
if ( type2.Eq(CBotTypArrayPointer) )
{
if ( nullptr == (i = CBotListArray::Compile(p, pStack, type2.GetTypElem())) )
{
if (pStack->IsOk())
{
i = CBotTwoOpExpr::Compile(p, pStack);
if (i == nullptr || !pStack->GetTypResult().Compare(type2))
{
pStack->SetError(CBotErrBadType1, p->GetStart());
return false;
}
}
}
}
else
{
// it has an assignmet to calculate
i = CBotTwoOpExpr::Compile(p, pStack);
if ( !(type.Eq(CBotTypPointer) && pStack->GetTypResult().Eq(CBotTypNullPointer)) &&
!TypesCompatibles( type2, pStack->GetTypResult()) )
{
pStack->SetError(CBotErrBadType1, p->GetStart());
return false;
}
}
if ( !pStack->IsOk() ) return false;
}
else if ( type2.Eq(CBotTypArrayPointer) ) i = new CBotExprLitNull();
if ( !bSecond )
{
CBotVar* pv = CBotVar::Create(pp, type);
CBotVar* pv = CBotVar::Create(pp, type2);
pv -> SetStatic( bStatic );
pv -> SetPrivate( mProtect );
@ -709,13 +734,23 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if ( pv->IsStatic() && pv->m_InitExpr != nullptr )
{
CBotStack* pile = CBotStack::AllocateStack(); // independent stack
if ( type2.Eq(CBotTypArrayPointer) )
{
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pv));
}
else
{
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile)); // evaluates the expression without timer
pv->SetVal( pile->GetVar() ) ;
}
pile->Delete();
}
}
else
{
delete i;
delete limites;
}
if ( IsOfType(p, ID_COMMA) ) continue;
if ( IsOfType(p, ID_SEP) ) break;
@ -744,10 +779,11 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
// TODO: Not sure how correct is that - I have no idea how the precompilation (Compile1 method) works ~krzys_h
std::string name = p->GetString();
CBotClass* pPapa = CBotClass::Find(name);
CBotToken* pp = p;
if (!IsOfType(p, TokenTypVar) || pPapa == nullptr)
{
pStack->SetError( CBotErrNotClass, p );
pStack->SetError(CBotErrNoClassName, pp);
return nullptr;
}
pOld->m_parent = pPapa;

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -26,6 +26,7 @@
#include <string>
#include <deque>
#include <set>
#include <list>
namespace CBot
{
@ -37,6 +38,7 @@ class CBotStack;
class CBotDefParam;
class CBotToken;
class CBotCStack;
class CBotExternalCallList;
/**
* \brief A CBot class definition
@ -102,7 +104,7 @@ class CBotCStack;
* float y = var->GetValFloat();
* \endcode
*/
class CBotClass : public CBotLinkedList<CBotClass>
class CBotClass
{
public:
/*!
@ -133,13 +135,8 @@ public:
bool intrinsic = false);
/*!
* \brief AddFunction This call allows to add as external new method
* used by the objects of this class. See (**) at end of this file for
* more details.
* \param name
* \param rExec
* \param rCompile
* \return
* \brief Add a function that can be called from CBot
* \see CBotProgram::AddFunction
*/
bool AddFunction(const std::string& name,
bool rExec(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
@ -176,7 +173,7 @@ public:
* \brief GetName Gives the name of the class.
* \return
*/
std::string GetName();
const std::string& GetName();
/*!
* \brief GetParent Gives the parent class (or nullptr).
@ -224,6 +221,13 @@ public:
*/
CBotVar* GetItemRef(int nIdent);
/*!
* \brief Check whether a variable is already defined in a class
* \param name Name of the variable
* \return True if a variable is defined in the class
*/
bool CheckVar(const std::string &name);
/*!
* \brief CompileMethode Compiles a method associated with an instance of
* class the method can be declared by the user or AddFunction.
@ -234,11 +238,11 @@ public:
* \param nIdent
* \return
*/
CBotTypResult CompileMethode(const std::string& name,
CBotTypResult CompileMethode(CBotToken* name,
CBotVar* pThis,
CBotVar** ppParams,
CBotCStack* pStack,
long& nIdent);
long &nIdent);
/*!
* \brief ExecuteMethode Executes a method.
@ -246,18 +250,13 @@ public:
* \param name
* \param pThis
* \param ppParams
* \param pResult
* \param pResultType
* \param pStack
* \param pToken
* \return
*/
bool ExecuteMethode(long& nIdent,
const std::string& name,
CBotVar* pThis,
CBotVar** ppParams,
CBotVar*& pResult,
CBotStack*& pStack,
CBotToken* pToken);
bool ExecuteMethode(long &nIdent, CBotVar* pThis, CBotVar** ppParams, CBotTypResult pResultType,
CBotStack*&pStack, CBotToken* pToken);
/*!
* \brief RestoreMethode Restored the execution stack.
@ -267,11 +266,11 @@ public:
* \param ppParams
* \param pStack
*/
void RestoreMethode(long& nIdent,
const std::string& name,
void RestoreMethode(long &nIdent,
CBotToken* name,
CBotVar* pThis,
CBotVar** ppParams,
CBotStack*& pStack);
CBotStack*&pStack);
/*!
* \brief Compile Compiles a class declared by the user.
@ -283,14 +282,33 @@ public:
CBotCStack* pStack);
/*!
* \brief Compile1
* \param p
* \param pStack
* \return
* \brief Pre-compile a new class
* \param p[in, out] Pointer to first token of the class, will be updated to point to first token after the class definition
* \param pStack Compile stack
*
* This function is used to find the beginning and end of class definition.
*
* If any errors in the code are detected, this function will set the error on compile stack and return nullptr.
*
* \return Precompiled class, or nullptr in case of error
*/
static CBotClass* Compile1(CBotToken* &p,
CBotCStack* pStack);
/*!
* \brief DefineClasses Calls CompileDefItem for each class in a list
* of classes, defining fields and pre-compiling methods.
* \param pClassList List of classes
* \param pStack
*/
static void DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pStack);
/*!
* \brief Get the list of user-defined methods in this class.
* \return List of methods, can be empty.
*/
const std::list<CBotFunction*>& GetFunctions() const;
/*!
* \brief CompileDefItem
* \param p
@ -319,18 +337,18 @@ public:
static void ClearPublic();
/*!
* \brief SaveStaticState
* \param pf
* \return
* \brief Save all static variables from each public class
* \param ostr Output stream
* \return true on success
*/
static bool SaveStaticState(FILE* pf);
static bool SaveStaticState(std::ostream &ostr);
/*!
* \brief RestoreStaticState
* \param pf
* \return
* \brief Restore all static variables in each public class
* \param istr Input stream
* \return true on success
*/
static bool RestoreStaticState(FILE* pf);
static bool RestoreStaticState(std::istream &istr);
/**
* \brief Request a lock on this class (for "synchronized" keyword)
@ -380,11 +398,13 @@ private:
//! Linked list of all class fields
CBotVar* m_pVar;
//! Linked list of all class external calls
CBotCallMethode* m_pCalls;
//! Linked list of all class methods
CBotFunction* m_pMethod;
CBotExternalCallList* m_externalMethods;
//! List of all class methods
std::list<CBotFunction*> m_pMethod{};
void (*m_rUpdate)(CBotVar* thisVar, void* user);
CBotToken* m_pOpenblk;
//! How many times the program currently holding the lock called Lock()
int m_lockCurrentCount = 0;
//! Programs waiting for lock. m_lockProg[0] is the program currently holding the lock, if any

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -23,10 +23,11 @@
#include "CBot/CBotInstr/CBotFunction.h"
#include "CBot/CBotInstr/CBotInstrCall.h"
#include <array>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/algorithm/string/replace.hpp>
namespace CBot
{
@ -36,12 +37,10 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
std::stringstream ss;
ss << "digraph {" << std::endl;
CBotFunction* func = program->GetFunctions();
std::map<long, CBotFunction*> funcIdMap;
while (func != nullptr)
for (CBotFunction* func : program->GetFunctions())
{
funcIdMap[func->m_nFuncIdent] = func;
func = func->Next();
}
std::set<CBotInstr*> finished;
@ -54,22 +53,34 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
instructions[ptr] = instructionsNextId++;
}
char buffer[20];
sprintf(buffer, "instr%d", instructions[ptr]);
return std::string(buffer);
std::array<char, 20> buffer;
snprintf(buffer.data(), buffer.size(), "instr%d", instructions[ptr]);
return std::string(buffer.data());
};
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
{
if (finished.find(instr) != finished.end()) return;
finished.insert(instr);
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
auto replaceAll = [](std::string& text, const std::string& from, const std::string& to)
{
std::size_t pos = 0;
while ((pos = text.find(from, pos)) != std::string::npos)
{
text.replace(pos, from.length(), to);
pos += to.length();
}
};
std::string data = instr->GetDebugData();
boost::algorithm::replace_all(data, "&", "&amp;");
boost::algorithm::replace_all(data, "<", "&lt;");
boost::algorithm::replace_all(data, ">", "&gt;");
replaceAll(data, "&", "&amp;");
replaceAll(data, "<", "&lt;");
replaceAll(data, ">", "&gt;");
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
label += data;
boost::algorithm::replace_all(label, "\n", "<br/>");
replaceAll(label, "\n", "<br/>");
std::string additional = "";
if (instr->GetDebugName() == "CBotFunction")
@ -111,9 +122,8 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
{
DumpInstr(program->m_entryPoint);
}
func = program->GetFunctions();
std::string prev = GetPointerAsString(program->m_entryPoint);
while (func != nullptr)
for (CBotFunction* func : program->GetFunctions())
{
if (func != program->m_entryPoint)
{
@ -122,8 +132,6 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
//ss << prev << " -> " << GetPointerAsString(func) << " [style=invis]" << std::endl;
prev = GetPointerAsString(func);
}
func = func->Next();
}
ss << "}" << std::endl;

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -19,6 +19,9 @@
#include "CBot/CBotDefParam.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotInstr/CBotParExpr.h"
#include "CBot/CBotUtils.h"
#include "CBot/CBotCStack.h"
@ -33,11 +36,13 @@ namespace CBot
CBotDefParam::CBotDefParam()
{
m_nIdent = 0;
m_expr = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
CBotDefParam::~CBotDefParam()
{
delete m_expr;
}
////////////////////////////////////////////////////////////////////////////////
@ -51,17 +56,16 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
if (IsOfType(p, ID_OPENPAR))
{
CBotDefParam* list = nullptr;
bool prevHasDefault = false;
while (!IsOfType(p, ID_CLOSEPAR))
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
{
CBotDefParam* param = new CBotDefParam();
if (list == nullptr) list = param;
else list->AddNext(param); // added to the list
// CBotClass* pClass = nullptr;//= CBotClass::Find(p);
param->m_typename = p->GetString();
CBotTypResult type = param->m_type = TypeParam(p, pStack);
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
if (param->m_type.GetType() > 0)
{
@ -77,19 +81,40 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
break;
}
if (IsOfType(p, ID_ASS)) // default value assignment
{
CBotCStack* pStk = pStack->TokenStack(nullptr, true);
if (nullptr != (param->m_expr = CBotParExpr::CompileLitExpr(p, pStk)))
{
CBotTypResult valueType = pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC);
if (!TypesCompatibles(type, valueType))
pStack->SetError(CBotErrBadType1, p->GetPrev());
prevHasDefault = true;
}
else pStack->SetError(CBotErrNoExpression, p);
pStack->DeleteNext();
}
else
if (prevHasDefault) pStack->SetError(CBotErrDefaultValue, p->GetPrev());
if (!pStack->IsOk()) break;
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
// if ( pClass ) var->SetClass(pClass);
var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized
param->m_nIdent = CBotVar::NextUniqNum();
var->SetUniqNum(param->m_nIdent);
pStack->AddVar(var); // place on the stack
if (IsOfType(p, ID_COMMA) || p->GetType() == ID_CLOSEPAR)
continue;
}
if (IsOfType(p, ID_COMMA)) continue;
if (IsOfType(p, ID_CLOSEPAR)) break;
pStack->SetError(CBotErrClosePar, p->GetStart());
}
pStack->SetError(CBotErrNoVar, p->GetStart());
}
pStack->SetError(CBotErrNoType, p);
delete list;
return nullptr;
@ -106,35 +131,91 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
int i = 0;
CBotDefParam* p = this;
bool useDefault = false;
CBotStack* pile = pj->AddStack();
while ( p != nullptr )
{
pile = pile->AddStack();
if (pile->StackOver()) return pj->Return(pile);
if (pile->GetState() == 1) // already done?
{
if (ppVars != nullptr && ppVars[i] != nullptr) ++i;
p = p->m_next;
continue; // next param
}
CBotVar* pVar = nullptr;
if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr))
{
useDefault = true; // end of arguments found
if (p->m_expr != nullptr) // has default expression ?
{
if (!p->m_expr->Execute(pile)) return false; // interupt here
pVar = pile->GetVar();
}
}
else
pVar = ppVars[i];
pile->SetState(1); // mark this param done
// creates a local variable on the stack
CBotVar* newvar = CBotVar::Create(p->m_token.GetString(), p->m_type);
// serves to make the transformation of types:
if ( ppVars != nullptr && ppVars[i] != nullptr )
if ((useDefault && pVar != nullptr) ||
(ppVars != nullptr && pVar != nullptr))
{
switch (p->m_type.GetType())
{
case CBotTypByte:
newvar->SetValByte(pVar->GetValByte());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypShort:
newvar->SetValShort(pVar->GetValShort());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypChar:
newvar->SetValChar(pVar->GetValChar());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypInt:
newvar->SetValInt(ppVars[i]->GetValInt());
newvar->SetValInt(pVar->GetValInt());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypLong:
newvar->SetValLong(pVar->GetValLong());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypFloat:
newvar->SetValFloat(ppVars[i]->GetValFloat());
newvar->SetValFloat(pVar->GetValFloat());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypDouble:
newvar->SetValDouble(pVar->GetValDouble());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypString:
newvar->SetValString(ppVars[i]->GetValString());
newvar->SetValString(pVar->GetValString());
break;
case CBotTypBoolean:
newvar->SetValInt(ppVars[i]->GetValInt());
newvar->SetValInt(pVar->GetValInt());
break;
case CBotTypIntrinsic:
(static_cast<CBotVarClass*>(newvar))->Copy(ppVars[i], false);
(static_cast<CBotVarClass*>(newvar))->Copy(pVar, false);
break;
case CBotTypPointer:
{
newvar->SetPointer(pVar->GetPointer());
newvar->SetType(p->m_type); // keep pointer type
}
break;
case CBotTypArrayPointer:
{
newvar->SetPointer(ppVars[i]->GetPointer());
newvar->SetPointer(pVar->GetPointer());
}
break;
default:
@ -144,23 +225,41 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
newvar->SetUniqNum(p->m_nIdent);
pj->AddVar(newvar); // add a variable
p = p->m_next;
i++;
if (!useDefault) i++;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotDefParam::HasDefault()
{
return (m_expr != nullptr);
}
////////////////////////////////////////////////////////////////////////////////
void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
{
// int i = 0;
CBotDefParam* p = this;
CBotStack* pile = nullptr;
if (bMain) pile = pj->RestoreStack();
while ( p != nullptr )
{
if (bMain && pile != nullptr)
{
pile = pile->RestoreStack();
if (pile != nullptr && pile->GetState() == 0)
{
assert(p->m_expr != nullptr);
p->m_expr->RestoreState(pile, true);
return;
}
}
// creates a local variable on the stack
CBotVar* var = pj->FindVar(p->m_token.GetString());
var->SetUniqNum(p->m_nIdent);
if (var != nullptr) var->SetUniqNum(p->m_nIdent);
p = p->m_next;
}
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -63,6 +63,12 @@ public:
*/
bool Execute(CBotVar** ppVars, CBotStack* &pj);
/*!
* \brief Check if this parameter has a default value expression.
* \return true if the parameter was compiled with a default value.
*/
bool HasDefault();
/*!
* \brief RestoreState
* \param pj
@ -96,6 +102,9 @@ private:
//! Type of paramteter.
CBotTypResult m_type;
long m_nIdent;
//! Default value expression for the parameter.
CBotInstr* m_expr;
};
} // namespace CBot

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -35,13 +35,13 @@ namespace CBot
enum CBotType
{
CBotTypVoid = 0, //!< void
CBotTypByte = 1, //!< byte (NOT IMPLEMENTED)
CBotTypShort = 2, //!< short (NOT IMPLEMENTED)
CBotTypChar = 3, //!< char (NOT IMPLEMENTED)
CBotTypByte = 1, //!< byte
CBotTypShort = 2, //!< short
CBotTypChar = 3, //!< char
CBotTypInt = 4, //!< int
CBotTypLong = 5, //!< long (NOT IMPLEMENTED)
CBotTypLong = 5, //!< long
CBotTypFloat = 6, //!< float
CBotTypDouble = 7, //!< double (NOT IMPLEMENTED)
CBotTypDouble = 7, //!< double
CBotTypBoolean = 8, //!< bool
CBotTypString = 9, //!< string
@ -100,12 +100,18 @@ enum TokenId
ID_STATIC,
ID_PROTECTED,
ID_PRIVATE,
ID_REPEAT,
ID_INT,
ID_FLOAT,
ID_BOOLEAN,
ID_STRING,
ID_VOID,
ID_BOOL,
ID_BYTE,
ID_SHORT,
ID_CHAR,
ID_LONG,
ID_DOUBLE,
TokenKeyVal = 2200, //!< keywords that represent values (true, false, null, nan)
ID_TRUE = 2200,
@ -177,7 +183,8 @@ enum TokenType
TokenTypNum = 2, //!< number
TokenTypString = 3, //!< string
TokenTypVar = 4, //!< a variable name
TokenTypDef = 5 //!< value according DefineNum
TokenTypDef = 5, //!< value according DefineNum
TokenTypChar = 6, //!< character literal
};
/**
@ -235,6 +242,20 @@ enum CBotError : int
CBotErrBadIndex = 5040, //!< wrong index type "[ false ]"
CBotErrPrivate = 5041, //!< protected item
CBotErrNoPublic = 5042, //!< missing word "public"
CBotErrNoExpression = 5043, //!< expression expected after =
CBotErrAmbiguousCall = 5044, //!< ambiguous call to overloaded function
CBotErrFuncNotVoid = 5045, //!< function needs return type "void"
CBotErrNoClassName = 5046, //!< class name expected
CBotErrNoReturn = 5047, //!< non-void function needs "return;"
CBotErrDefaultValue = 5048, //!< this parameter needs a default value
CBotErrEndQuote = 5049, //!< missing end quote
CBotErrBadEscape = 5050, //!< unknown escape sequence
CBotErrOctalRange = 5051, //!< octal value out of range
CBotErrHexDigits = 5052, //!< missing hex digits after escape sequence
CBotErrHexRange = 5053, //!< hex value out of range
CBotErrUnicodeName = 5054, //!< invalid universal character name
CBotErrCharEmpty = 5055, //!< empty character constant
CBotErrRedefCase = 5056, //!< duplicate label in switch
// Runtime errors
CBotErrZeroDiv = 6000, //!< division by zero

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -82,19 +82,23 @@ int CBotExternalCallList::DoCall(CBotToken* token, CBotVar* thisVar, CBotVar** p
CBotExternalCall* pt = m_list[token->GetString()].get();
if (pStack->IsCallFinished()) return true;
CBotStack* pile = pStack->AddStackExternalCall(pt);
if (thisVar == nullptr && pStack->IsCallFinished()) return true; // only for non-method external call
// lists the parameters depending on the contents of the stack (pStackVar)
// if this is a method call we need to use AddStack()
CBotStack* pile = (thisVar != nullptr) ? pStack->AddStack() : pStack->AddStackExternalCall(pt);
if (pile->GetState() == 0) // the first time?
{
// lists the parameters depending on the contents of the stack
CBotVar* pVar = MakeListVars(ppVar, true);
// creates a variable to the result
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
pile->SetVar(pVar);
CBotStack* pile2 = pile->AddStack();
// creates a variable to the result
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
pile2->SetVar(pResult);
pile->IncState(); // increment state to mark this step done
}
pile->SetError(CBotNoErr, token); // save token for the position in case of error
return pt->Run(thisVar, pStack);
@ -107,7 +111,8 @@ bool CBotExternalCallList::RestoreCall(CBotToken* token, CBotVar* thisVar, CBotV
CBotExternalCall* pt = m_list[token->GetString()].get();
CBotStack* pile = pStack->RestoreStackEOX(pt);
// if this is a method call we need to use RestoreStack()
CBotStack* pile = (thisVar != nullptr) ? pStack->RestoreStack() : pStack->RestoreStackEOX(pt);
if (pile == nullptr) return true;
pile->RestoreStack();
@ -163,9 +168,51 @@ bool CBotExternalCallDefault::Run(CBotVar* thisVar, CBotStack* pStack)
return false;
}
if (result != nullptr) pStack->SetCopyVar(result);
pStack->Return(pile2); // return 'result' and clear extra stack
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CBotExternalCallClass::CBotExternalCallClass(RuntimeFunc rExec, CompileFunc rCompile)
{
m_rExec = rExec;
m_rComp = rCompile;
}
CBotExternalCallClass::~CBotExternalCallClass()
{
}
CBotTypResult CBotExternalCallClass::Compile(CBotVar* thisVar, CBotVar* args, void* user)
{
return m_rComp(thisVar, args);
}
bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
{
assert(thisVar != nullptr);
CBotStack* pile = pStack->AddStack();
CBotVar* args = pile->GetVar();
CBotStack* pile2 = pile->AddStack();
CBotVar* result = pile2->GetVar();
int exception = CBotNoErr; // TODO: Change to CBotError
bool res = m_rExec(thisVar, args, result, exception, pStack->GetUserPtr());
if (!res)
{
if (exception != CBotNoErr)
{
pStack->SetError(static_cast<CBotError>(exception));
}
return false;
}
pStack->Return(pile2); // return 'result' and clear extra stack
return true;
}
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -105,6 +105,36 @@ private:
CompileFunc m_rComp;
};
/**
* \brief Implementation of CBot external call for class methods, using compilation and runtime functions
*/
class CBotExternalCallClass : public CBotExternalCall
{
public:
typedef bool (*RuntimeFunc)(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user);
typedef CBotTypResult (*CompileFunc)(CBotVar* pThis, CBotVar*& pVar);
/**
* \brief Constructor
* \param rExec Runtime function
* \param rCompile Compilation function
* \see CBotProgram::AddFunction()
*/
CBotExternalCallClass(RuntimeFunc rExec, CompileFunc rCompile);
/**
* \brief Destructor
*/
virtual ~CBotExternalCallClass();
virtual CBotTypResult Compile(CBotVar* thisVar, CBotVar* args, void* user) override;
virtual bool Run(CBotVar* thisVar, CBotStack* pStack) override;
private:
RuntimeFunc m_rExec;
CompileFunc m_rComp;
};
/**
* \brief Class for mangaging CBot external calls

View File

@ -0,0 +1,367 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "CBot/CBotFileUtils.h"
#include "CBot/CBotClass.h"
#include "CBot/CBotEnums.h"
namespace CBot
{
template<typename T>
static bool WriteBinary(std::ostream &ostr, T value, unsigned padTo = 0)
{
unsigned char chr;
unsigned count = 1;
while (value > 127) // unsigned LEB128
{
++count;
chr = (value & 0x7F) | 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
value >>= 7;
}
chr = value & 0x7F;
if (count < padTo) chr |= 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
if (count < padTo)
{
while (++count < padTo)
if (!(ostr << '\x80')) return false;
if (!(ostr << '\x00')) return false;
}
return true;
}
template<typename T>
static bool ReadBinary(std::istream &istr, T &value)
{
value = 0;
unsigned char chr;
unsigned shift = 0;
while (true) // unsigned LEB128
{
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
if (shift < sizeof(T) * 8)
value |= static_cast<T>(chr & 0x7F) << shift;
shift += 7;
if ((chr & 0x80) == 0) break;
}
return true;
}
template<typename T>
static bool WriteSignedBinary(std::ostream &ostr, T value, unsigned padTo = 0)
{
signed char sign = value >> (8 * sizeof(T) - 1);
unsigned count = 0;
while (true) // signed LEB128
{
++count;
unsigned char chr = value & 0x7F;
value >>= 7;
if (!(value != sign || ((chr ^ sign) & 0x40) != 0))
{
if (count < padTo) chr |= 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
break;
}
chr |= 0x80;
if (!ostr.put(chr)) return false;
}
if (count < padTo)
{
char chr = (sign < 0) ? 0x7F : 0x00;
while (++count < padTo)
if (!ostr.put(chr | 0x80)) return false;
if (!ostr.put(chr)) return false;
}
return true;
}
template<typename T>
static bool ReadSignedBinary(std::istream &istr, T &value)
{
value = 0;
unsigned char chr;
unsigned shift = 0;
while (true) // signed LEB128
{
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
if (shift < sizeof(T) * 8 - 1)
value |= (static_cast<T>(chr & 0x7F) << shift);
shift += 7;
if ((chr & 0x80) == 0) break;
}
if (shift >= 8 * sizeof(T) - 1) shift = 8 * sizeof(T) - 1;
if ((chr & 0x40) != 0)
value |= static_cast<T>(-1) << shift;
return true;
}
bool WriteWord(std::ostream &ostr, unsigned short w)
{
return WriteBinary<unsigned short>(ostr, w);
}
bool ReadWord(std::istream &istr, unsigned short &w)
{
return ReadBinary<unsigned short>(istr, w);
}
bool WriteByte(std::ostream &ostr, char c)
{
if (!ostr.put(c)) return false;
return true;
}
bool ReadByte(std::istream &istr, char& c)
{
if (!istr.get(c)) return false;
return true;
}
bool WriteShort(std::ostream &ostr, short s)
{
return WriteSignedBinary<short>(ostr, s);
}
bool ReadShort(std::istream &istr, short &s)
{
return ReadSignedBinary<short>(istr, s);
}
bool WriteUInt32(std::ostream &ostr, uint32_t i)
{
return WriteBinary<uint32_t>(ostr, i);
}
bool ReadUInt32(std::istream &istr, uint32_t &i)
{
return ReadBinary<uint32_t>(istr, i);
}
bool WriteInt(std::ostream &ostr, int i)
{
return WriteSignedBinary<int>(ostr, i);
}
bool ReadInt(std::istream &istr, int &i)
{
return ReadSignedBinary<int>(istr, i);
}
bool WriteLong(std::ostream &ostr, long l, unsigned padTo)
{
return WriteSignedBinary<long>(ostr, l, padTo);
}
bool ReadLong(std::istream &istr, long &l)
{
return ReadSignedBinary<long>(istr, l);
}
bool WriteFloat(std::ostream &ostr, float f)
{
union TypeConverter
{
float fValue;
uint32_t iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
u.fValue = f;
return WriteBinary<uint32_t>(ostr, u.iValue);
}
bool ReadFloat(std::istream &istr, float &f)
{
union TypeConverter
{
float fValue;
uint32_t iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
if (!ReadBinary<uint32_t>(istr, u.iValue)) return false;
f = u.fValue;
return true;
}
bool WriteDouble(std::ostream &ostr, double d)
{
union TypeConverter
{
double dValue;
uint64_t iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
u.dValue = d;
return WriteBinary<uint64_t>(ostr, u.iValue);
}
bool ReadDouble(std::istream &istr, double &d)
{
union TypeConverter
{
double dValue;
uint64_t iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
if (!ReadBinary<uint64_t>(istr, u.iValue)) return false;
d = u.dValue;
return true;
}
bool WriteString(std::ostream &ostr, const std::string &s)
{
if (!WriteBinary<size_t>(ostr, s.size())) return false;
if (!ostr.write(&(s[0]), s.size())) return false;
return true;
}
bool ReadString(std::istream &istr, std::string &s)
{
size_t length = 0;
if (!ReadBinary<size_t>(istr, length)) return false;
s.resize(length);
if (length != 0)
{
if (!istr.read(&(s[0]), length)) return false;
}
return true;
}
bool WriteType(std::ostream &ostr, const CBotTypResult &type)
{
int typ = type.GetType();
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
if ( !WriteWord(ostr, typ) ) return false;
if ( typ == CBotTypClass )
{
CBotClass* p = type.GetClass();
if (!WriteString(ostr, p->GetName())) return false;
}
if ( type.Eq( CBotTypArrayBody ) ||
type.Eq( CBotTypArrayPointer ) )
{
if (!WriteWord(ostr, type.GetLimite())) return false;
if (!WriteType(ostr, type.GetTypElem())) return false;
}
if ( type.Eq(CBotTypPointer) )
{
if (type.GetClass() != nullptr)
{
if (!WriteString(ostr, type.GetClass()->GetName())) return false;
}
else if (!WriteString(ostr, "")) return false;
}
return true;
}
bool ReadType(std::istream &istr, CBotTypResult &type)
{
unsigned short w, ww;
if (!ReadWord(istr, w)) return false;
type.SetType(w);
if ( type.Eq( CBotTypIntrinsic ) )
{
type = CBotTypResult( w, "point" );
}
if ( type.Eq( CBotTypClass ) )
{
std::string s;
if (!ReadString(istr, s)) return false;
type = CBotTypResult( w, s );
}
if ( type.Eq( CBotTypArrayPointer ) ||
type.Eq( CBotTypArrayBody ) )
{
CBotTypResult r;
if (!ReadWord(istr, ww)) return false;
if (!ReadType(istr, r)) return false;
type = CBotTypResult( w, r );
type.SetLimite(static_cast<short>(ww));
}
if ( type.Eq(CBotTypPointer) )
{
std::string className;
if (!ReadString(istr, className)) return false;
type = CBotTypResult(w, className);
}
return true;
}
bool WriteStream(std::ostream &ostr, std::istream& istr)
{
if (!istr.seekg(0, istr.end)) return false;
auto size = istr.tellg();
if (size == 0) return WriteLong(ostr, 0);
if (!WriteLong(ostr, size)) return false;
if (!istr.seekg(0, istr.beg)) return false;
while (size > 0)
{
size -= 1;
if (!ostr.put(istr.get())) return false;
}
return true;
}
bool ReadStream(std::istream& istr, std::ostream &ostr)
{
long length;
if (!ReadLong(istr, length)) return false;
if (length == 0) return true;
while (length-- > 0)
{
if (!ostr.put(istr.get())) return false;
}
return true;
}
} // namespace CBot

View File

@ -0,0 +1,217 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include <cstdint>
#include <iostream>
#include <string>
namespace CBot
{
class CBotVar;
class CBotTypResult;
/*!
* \brief Save a linked list if variables
* \param ostr Output stream
* \param pVar First variable in the list
* \return true on success
*/
bool SaveVars(std::ostream &ostr, CBotVar* pVar);
/*!
* \brief WriteWord
* \param ostr Output stream
* \param w
* \return true on success
*/
bool WriteWord(std::ostream &ostr, unsigned short w);
/*!
* \brief ReadWord
* \param istr Input stream
* \param[out] w
* \return true on success
*/
bool ReadWord(std::istream &istr, unsigned short &w);
/*!
* \brief WriteByte
* \param ostr Output stream
* \param c
* \return true on success
*/
bool WriteByte(std::ostream &ostr, char c);
/*!
* \brief ReadByte
* \param istr Input stream
* \param[out] c
* \return true on success
*/
bool ReadByte(std::istream &istr, char& c);
/*!
* \brief WriteShort
* \param ostr Output stream
* \param s
* \return true on success
*/
bool WriteShort(std::ostream &ostr, short s);
/*!
* \brief ReadShort
* \param istr Input stream
* \param[out] s
* \return true on success
*/
bool ReadShort(std::istream &istr, short &s);
/*!
* \brief WriteUInt32
* \param ostr Output stream
* \param i
* \return true on success
*/
bool WriteUInt32(std::ostream &ostr, uint32_t i);
/*!
* \brief ReadUInt32
* \param istr Input stream
* \param[out] i
* \return true on success
*/
bool ReadUInt32(std::istream &istr, uint32_t &i);
/*!
* \brief WriteInt
* \param ostr Output stream
* \param i
* \return true on success
*/
bool WriteInt(std::ostream &ostr, int i);
/*!
* \brief ReadInt
* \param istr Input stream
* \param[out] i
* \return true on success
*/
bool ReadInt(std::istream &istr, int &i);
/*!
* \brief WriteLong
* \param ostr Output stream
* \param l
* \param padTo minimum number of bytes to write
* \return true on success
*/
bool WriteLong(std::ostream &ostr, long l, unsigned padTo = 0);
/*!
* \brief ReadLong
* \param istr Input stream
* \param[out] l
* \return true on success
*/
bool ReadLong(std::istream &istr, long &l);
/*!
* \brief WriteFloat
* \param ostr Output stream
* \param f
* \return true on success
*/
bool WriteFloat(std::ostream &ostr, float f);
/*!
* \brief ReadFloat
* \param istr Input stream
* \param[out] f
* \return true on success
*/
bool ReadFloat(std::istream &istr, float &f);
/*!
* \brief WriteDouble
* \param ostr Output stream
* \param d
* \return true on success
*/
bool WriteDouble(std::ostream &ostr, double d);
/*!
* \brief ReadDouble
* \param istr Input stream
* \param[out] d
* \return true on success
*/
bool ReadDouble(std::istream &istr, double &d);
/*!
* \brief WriteString
* \param ostr Output stream
* \param s
* \return true on success
*/
bool WriteString(std::ostream &ostr, const std::string &s);
/*!
* \brief ReadString
* \param istr Input stream
* \param[out] s
* \return true on success
*/
bool ReadString(std::istream &istr, std::string &s);
/*!
* \brief WriteType
* \param ostr Output stream
* \param type
* \return true on success
*/
bool WriteType(std::ostream &ostr, const CBotTypResult &type);
/*!
* \brief ReadType
* \param istr Input stream
* \param[out] type
* \return true on success
*/
bool ReadType(std::istream &istr, CBotTypResult &type);
/*!
* \brief WriteStream
* \param ostr Output stream
* \param istr Input stream
* \return true on success
*/
bool WriteStream(std::ostream &ostr, std::istream& istr);
/*!
* \brief ReadStream
* \param istr Input stream
* \param ostr Output stream
* \return true on success
*/
bool ReadStream(std::istream& istr, std::ostream &ostr);
} // namespace CBot

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,137 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "CBot/CBotInstr/CBotCase.h"
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
namespace CBot
{
////////////////////////////////////////////////////////////////////////////////
CBotCase::CBotCase()
{
m_instr = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
CBotCase::~CBotCase()
{
delete m_instr;
}
CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack, std::unordered_map<long, CBotInstr*>& labels)
{
CBotToken* pp = p; // preserves at the ^ token (starting position)
if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return nullptr; // should never happen
pStack->SetStartError(pp->GetStart());
long labelValue = 0;
if (pp->GetType() == ID_CASE)
{
CBotInstr* i = nullptr;
if (nullptr != (i = CBotTwoOpExpr::Compile(p, pStack, nullptr, true)))
{
if (pStack->GetType() <= CBotTypLong)
{
CBotStack* pile = CBotStack::AllocateStack();
while ( !i->Execute(pile) );
labelValue = pile->GetVar()->GetValLong();
pile->Delete();
if (labels.count(labelValue) > 0)
{
pStack->SetError(CBotErrRedefCase, p->GetStart());
}
}
else
pStack->SetError(CBotErrBadNum, p->GetStart());
delete i;
}
else
pStack->SetError(CBotErrBadNum, p->GetStart());
}
if (pStack->IsOk() && IsOfType(p, ID_DOTS))
{
CBotCase* newCase = new CBotCase();
newCase->SetToken(pp);
if (pp->GetType() == ID_CASE)
labels[labelValue] = newCase;
return newCase;
}
pStack->SetError(CBotErrNoDoubleDots, p->GetStart());
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotCase::Execute(CBotStack* &pj)
{
if (m_instr == nullptr) return true;
CBotStack* pile = pj->AddStack(this, CBotStack::BlockVisibilityType::BLOCK);
int state = pile->GetState();
CBotInstr* p = m_instr;
while (state-- > 0) p = p->GetNext();
while (p != nullptr)
{
if (!p->Execute(pile)) return false;
pile->IncState();
p = p->GetNext();
}
pile->Delete();
return pj->IsOk();
}
////////////////////////////////////////////////////////////////////////////////
void CBotCase::RestoreState(CBotStack* &pj, bool bMain)
{
if (!bMain) return;
CBotStack* pile = pj->RestoreStack(this);
if (pile == nullptr) return;
CBotInstr* p = m_instr;
int state = pile->GetState();
while (p != nullptr && state-- > 0)
{
p->RestoreState(pile, bMain);
p = p->GetNext();
}
if (p != nullptr) p->RestoreState(pile, bMain);
}
std::map<std::string, CBotInstr*> CBotCase::GetDebugLinks()
{
auto links = CBotInstr::GetDebugLinks();
links["m_instr"] = m_instr;
return links;
}
} // namespace CBot

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -72,20 +72,27 @@ CBotInstr* CBotDefArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResul
CBotInstr* i;
while (IsOfType(p, ID_OPBRK))
{
pStk->SetStartError(p->GetStart());
if (p->GetType() != ID_CLBRK)
{
i = CBotExpression::Compile(p, pStk); // expression for the value
if (i == nullptr || pStk->GetType() != CBotTypInt) // must be a number
{
pStk->SetError(CBotErrBadIndex, p->GetStart());
goto error;
}
}
else
i = new CBotEmpty(); // if no special formula
inst->AddNext3b(i); // construct a list
type = CBotTypResult(CBotTypArrayPointer, type);
if (!pStk->IsOk() || !IsOfType(p, ID_CLBRK ))
{
if (IsOfType(p, ID_CLBRK)) continue;
pStk->SetError(CBotErrCloseIndex, p->GetStart());
goto error;
}
}
CBotVar* var = CBotVar::Create(*vartoken, type); // create an instance
inst->m_typevar = type;
@ -96,17 +103,32 @@ CBotInstr* CBotDefArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResul
if (IsOfType(p, ID_ASS)) // with an assignment
{
if ((inst->m_listass = CBotTwoOpExpr::Compile(p, pStk)) != nullptr)
pStk->SetStartError(p->GetStart());
if ( IsOfType(p, ID_SEP) )
{
if (!pStk->GetTypResult().Compare(type)) // compatible type ?
pStk->SetError(CBotErrNoExpression, p->GetPrev());
goto error;
}
if ( nullptr == (inst->m_listass = CBotListArray::Compile(p, pStk, type.GetTypElem())) )
{
if (pStk->IsOk())
{
inst->m_listass = CBotTwoOpExpr::Compile(p, pStk);
if (inst->m_listass == nullptr || !pStk->GetTypResult().Compare(type)) // compatible type ?
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
}
}
else
}
if (pStk->IsOk()) while (true) // mark initialized
{
inst->m_listass = CBotListArray::Compile(p, pStk, type.GetTypElem());
var = var->GetItem(0, true);
if (var == nullptr) break;
if (var->GetType() == CBotTypArrayPointer) continue;
if (var->GetType() <= CBotTypString) var->SetInit(CBotVar::InitType::DEF);
break;
}
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -82,16 +82,17 @@ CBotInstr* CBotDefBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont,
inst = static_cast<CBotDefBoolean*>(CBotDefArray::Compile(p, pStk, CBotTypBoolean));
if (!pStk->IsOk() )
{
pStk->SetError(CBotErrCloseIndex, p->GetStart());
goto error;
}
goto suite; // no assignment, variable already created
}
if (IsOfType(p, ID_ASS))
{
pStk->SetStartError(p->GetStart());
if ( IsOfType(p, ID_SEP) )
{
pStk->SetError(CBotErrNoExpression, p->GetStart());
goto error;
}
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
{
goto error;
@ -109,7 +110,7 @@ CBotInstr* CBotDefBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont,
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
pStack->AddVar(var);
suite:
if (IsOfType(p, ID_COMMA))
if (pStk->IsOk() && IsOfType(p, ID_COMMA))
{
if (nullptr != ( inst->m_next2b = CBotDefBoolean::Compile(p, pStk, true, noskip)))
{

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -19,6 +19,7 @@
#include "CBot/CBotInstr/CBotDefClass.h"
#include "CBot/CBotInstr/CBotExprRetVar.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotInstr/CBotLeftExprVar.h"
@ -44,11 +45,15 @@ CBotDefClass::CBotDefClass()
m_expr = nullptr;
m_hasParams = false;
m_nMethodeIdent = 0;
m_exprRetVar = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
CBotDefClass::~CBotDefClass()
{
delete m_parameters;
delete m_exprRetVar;
delete m_expr;
delete m_var;
}
@ -101,11 +106,6 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
inst = static_cast<CBotDefClass*>(CBotDefArray::Compile(p, pStk, type ));
if (!pStk->IsOk() )
{
pStk->SetError(CBotErrCloseIndex, p->GetStart());
goto error;
}
goto suite; // no assignment, variable already created
}
@ -134,13 +134,13 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
{
// the constructor is there?
// std::string noname;
CBotTypResult r = pClass->CompileMethode(pClass->GetName(), var, ppVars, pStk, inst->m_nMethodeIdent);
delete pStk->TokenStack(); // releases the supplement stack
CBotTypResult r = pClass->CompileMethode(&token, var, ppVars, pStk, inst->m_nMethodeIdent);
pStk->DeleteNext(); // releases the supplement stack
int typ = r.GetType();
if (typ == CBotErrUndefCall)
{
// si le constructeur n'existe pas
// if the ctor don't exist
if (inst->m_parameters != nullptr) // with parameters
{
pStk->SetError(CBotErrNoConstruct, vartoken);
@ -155,16 +155,33 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
goto error;
}
pStk->SetCopyVar(var);
// chained method ?
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
{
inst->m_exprRetVar->SetToken(vartoken);
pStk->DeleteNext();
}
pStk->SetVar(nullptr);
if ( !pStk->IsOk() ) goto error;
}
if (IsOfType(p, ID_ASS)) // with a assignment?
{
pStk->SetStartError(p->GetStart());
if (inst->m_hasParams)
{
pStk->SetError(CBotErrNoTerminator, p->GetStart());
goto error;
}
if ( IsOfType(p, ID_SEP) )
{
pStk->SetError(CBotErrNoExpression, p->GetStart());
goto error;
}
if ( nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) )
{
goto error;
@ -172,7 +189,8 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
CBotClass* result = pStk->GetClass();
if ( !pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_POINTER).Eq(CBotTypNullPointer) &&
( !pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_POINTER).Eq(CBotTypPointer) ||
( result != nullptr && !pClass->IsChildOf(result) ))) // type compatible ?
( result != nullptr && !(pClass->IsChildOf(result) ||
result->IsChildOf(pClass))))) // type compatible ?
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
@ -200,7 +218,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
var->SetInit(CBotVar::InitType::IS_POINTER); // marks the pointer as init
}
suite:
if (IsOfType(p, ID_COMMA)) // several chained definitions
if (pStk->IsOk() && IsOfType(p, ID_COMMA)) // several chained definitions
{
if ( nullptr != ( inst->m_next = CBotDefClass::Compile(p, pStk, pClass) )) // compiles the following
{
@ -208,7 +226,7 @@ suite:
}
}
if (IsOfType(p, ID_SEP)) // complete instruction
if (!pStk->IsOk() || IsOfType(p, ID_SEP)) // complete instruction
{
return pStack->Return(inst, pStk);
}
@ -229,6 +247,19 @@ bool CBotDefClass::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this);//essential for SetState()
// if ( pile == EOX ) return true;
if (m_exprRetVar != nullptr) // Class c().method();
{
if (pile->GetState() == 4)
{
if (pile->IfStep()) return false;
CBotStack* pile3 = pile->AddStack();
if (!m_exprRetVar->Execute(pile3)) return false;
pile3->SetVar(nullptr);
pile->Return(pile3); // release pile3 stack
pile->SetState(5);
}
}
CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt);
@ -266,9 +297,10 @@ bool CBotDefClass::Execute(CBotStack* &pj)
// evaluates the expression for the assignment
if (!m_expr->Execute(pile)) return false;
CBotVar* pv = pile->GetVar();
if ( bIntrincic )
{
CBotVar* pv = pile->GetVar();
if ( pv == nullptr || pv->GetPointer() == nullptr )
{
pile->SetError(CBotErrNull, &m_token);
@ -278,9 +310,20 @@ bool CBotDefClass::Execute(CBotStack* &pj)
}
else
{
if ( !(pv == nullptr || pv->GetPointer() == nullptr) )
{
if ( !pv->GetClass()->IsChildOf(pClass))
{
pile->SetError(CBotErrBadType1, &m_token);
return pj->Return(pile);
}
}
CBotVarClass* pInstance;
pInstance = (static_cast<CBotVarPointer*>(pile->GetVar()))->GetPointer(); // value for the assignment
pInstance = pv->GetPointer(); // value for the assignment
CBotTypResult type = pThis->GetTypResult();
pThis->SetPointer(pInstance);
pThis->SetType(type); // keep pointer type
}
pThis->SetInit(CBotVar::InitType::DEF);
}
@ -317,6 +360,7 @@ bool CBotDefClass::Execute(CBotStack* &pj)
if ( p != nullptr) while ( true )
{
pile2 = pile2->AddStack(); // place on the stack for the results
if (pile2->StackOver()) return pj->Return(pile2);
if ( pile2->GetState() == 0 )
{
if (!p->Execute(pile2)) return false; // interrupted here?
@ -329,11 +373,7 @@ bool CBotDefClass::Execute(CBotStack* &pj)
ppVars[i] = nullptr;
// creates a variable for the result
CBotVar* pResult = nullptr; // constructor still void
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
pThis, ppVars,
pResult, pile2, GetToken())) return false; // interrupt
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pThis, ppVars, CBotTypResult(CBotTypVoid), pile2, GetToken())) return false; // interrupt
pThis->SetInit(CBotVar::InitType::DEF);
pThis->ConstructorSet(); // indicates that the constructor has been called
@ -348,6 +388,14 @@ bool CBotDefClass::Execute(CBotStack* &pj)
pile->SetState(3); // finished this part
}
if (m_exprRetVar != nullptr && pile->GetState() == 3) // Class c().method();
{
CBotStack* pile3 = pile->AddStack();
pile3->SetCopyVar(pThis);
pile->SetState(4);
return false; // go back to the top ^^^
}
if ( pile->IfStep() ) return false;
if ( m_next2b != nullptr &&
@ -372,6 +420,16 @@ void CBotDefClass::RestoreState(CBotStack* &pj, bool bMain)
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute a unique number
}
if (m_exprRetVar != nullptr) // Class c().method();
{
if (pile->GetState() == 4)
{
CBotStack* pile3 = pile->RestoreStack();
m_exprRetVar->RestoreState(pile3, bMain);
return;
}
}
CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt);
bool bIntrincic = pClass->IsIntrinsic();
@ -425,9 +483,7 @@ void CBotDefClass::RestoreState(CBotStack* &pj, bool bMain)
ppVars[i] = nullptr;
// creates a variable for the result
// CBotVar* pResult = nullptr; // constructor still void
pClass->RestoreMethode(m_nMethodeIdent, pClass->GetName(), pThis, ppVars, pile2);
pClass->RestoreMethode(m_nMethodeIdent, pt, pThis, ppVars, pile2);
return;
}
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -85,6 +85,9 @@ private:
//! Constructor method unique identifier
long m_nMethodeIdent;
//! Instruction to chain method calls after constructor
CBotInstr* m_exprRetVar;
};
} // namespace CBot

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -20,6 +20,7 @@
#include "CBot/CBotInstr/CBotDefString.h"
#include "CBot/CBotInstr/CBotLeftExprVar.h"
#include "CBot/CBotInstr/CBotDefArray.h"
#include "CBot/CBotInstr/CBotTwoOpExpr.h"
#include "CBot/CBotStack.h"
@ -61,6 +62,7 @@ CBotInstr* CBotDefString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont,
inst->m_expr = nullptr;
CBotToken* vartoken = p;
CBotVar* var = nullptr;
inst->SetToken(vartoken);
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
@ -73,8 +75,27 @@ CBotInstr* CBotDefString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont,
goto error;
}
if (IsOfType(p, ID_OPBRK))
{
delete inst; // type is not CBotDefString
p = vartoken; // returns the variable name
// compiles an array declaration
CBotInstr* inst2 = CBotDefArray::Compile(p, pStk, CBotTypString);
inst = static_cast<CBotDefString*>(inst2);
goto suite; // no assignment, variable already created
}
if (IsOfType(p, ID_ASS))
{
pStk->SetStartError(p->GetStart());
if ( IsOfType(p, ID_SEP) )
{
pStk->SetError(CBotErrNoExpression, p->GetStart());
goto error;
}
if (nullptr == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )))
{
goto error;
@ -86,13 +107,13 @@ CBotInstr* CBotDefString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont,
}*/
}
CBotVar* var = CBotVar::Create(*vartoken, CBotTypString);
var = CBotVar::Create(*vartoken, CBotTypString);
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
var->SetUniqNum(
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
pStack->AddVar(var);
if (IsOfType(p, ID_COMMA))
suite:
if (pStk->IsOk() && IsOfType(p, ID_COMMA))
{
if (nullptr != ( inst->m_next2b = CBotDefString::Compile(p, pStk, true, noskip)))
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,151 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "CBot/CBotInstr/CBotExprLitChar.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
#include "CBot/CBotVar/CBotVar.h"
namespace CBot
{
CBotExprLitChar::CBotExprLitChar()
{
}
CBotExprLitChar::~CBotExprLitChar()
{
}
CBotInstr* CBotExprLitChar::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotCStack* pStk = pStack->TokenStack();
const auto& s = p->GetString();
auto it = s.cbegin();
if (++it != s.cend())
{
if (*it != '\'') // not empty quotes ?
{
uint32_t valchar = 0;
int pos = p->GetStart() + 1;
if (*it != '\\') valchar = *(it++); // not escape sequence ?
else if (++it != s.cend())
{
pStk->SetStartError(pos++);
unsigned char c = *(it++);
if (c == '\"' || c == '\'' || c == '\\') valchar = c;
else if (c == 'a') valchar = '\a'; // alert bell
else if (c == 'b') valchar = '\b'; // backspace
else if (c == 'f') valchar = '\f'; // form feed
else if (c == 'n') valchar = '\n'; // new line
else if (c == 'r') valchar = '\r'; // carriage return
else if (c == 't') valchar = '\t'; // horizontal tab
else if (c == 'v') valchar = '\v'; // vertical tab
else if (c == 'u' || c == 'U') // unicode escape
{
if (it != s.cend())
{
std::string hex = "";
size_t maxlen = (c == 'u') ? 4 : 8;
for (size_t i = 0; i < maxlen; i++)
{
if (!CharInList(*it, "0123456789ABCDEFabcdef")) break;
++pos;
hex += *it;
if (++it == s.cend()) break;
}
if (maxlen == hex.length()) // unicode character
{
try
{
valchar = std::stoi(hex, nullptr, 16);
if (0x10FFFF < valchar || (0xD7FF < valchar && valchar < 0xE000))
pStk->SetError(CBotErrUnicodeName, pos + 1);
}
catch (const std::out_of_range& e)
{
pStk->SetError(CBotErrHexRange, pos + 1);
}
}
else
pStk->SetError(CBotErrHexDigits, pos + 1);
}
else
pStk->SetError(CBotErrHexDigits, pos + 1);
}
else
pStk->SetError(CBotErrBadEscape, pos + 1);
}
if (it == s.cend() || *it != '\'')
pStk->SetError(CBotErrEndQuote, p);
if (pStk->IsOk())
{
CBotExprLitChar* inst = new CBotExprLitChar();
inst->m_valchar = valchar;
inst->SetToken(p);
p = p->GetNext();
CBotVar* var = CBotVar::Create("", CBotTypChar);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
}
pStk->SetError(CBotErrCharEmpty, p);
}
pStk->SetError(CBotErrEndQuote, p);
return pStack->Return(nullptr, pStk);
}
bool CBotExprLitChar::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", CBotTypChar);
var->SetValChar(m_valchar);
pile->SetVar(var);
return pj->Return(pile);
}
void CBotExprLitChar::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}
std::string CBotExprLitChar::GetDebugData()
{
return m_token.GetString();
}
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -19,41 +19,44 @@
#pragma once
#include "CBot/CBotVar/CBotVar.h"
#include "CBot/CBotInstr/CBotInstr.h"
#include <cstdint>
namespace CBot
{
/**
* \brief CBotVar subclass for managing string values (::CBotTypString)
* \brief A character literal
* \verbatim 'a', '\n', '\t', '\uFFFD', '\U0000FFFD', etc. \endverbatim
*/
class CBotVarString : public CBotVar
class CBotExprLitChar : public CBotInstr
{
public:
/**
* \brief Constructor. Do not call directly, use CBotVar::Create()
CBotExprLitChar();
~CBotExprLitChar();
/*!
* \brief Compile a character literal
*/
CBotVarString(const CBotToken& name);
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
void SetValString(const std::string& val) override;
std::string GetValString() override;
/*!
* \brief Execute, returns the corresponding char.
*/
bool Execute(CBotStack* &pj) override;
void Copy(CBotVar* pSrc, bool bName = true) override;
/*!
* \brief RestoreState
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
void Add(CBotVar* left, CBotVar* right) override;
bool Lo(CBotVar* left, CBotVar* right) override;
bool Hi(CBotVar* left, CBotVar* right) override;
bool Ls(CBotVar* left, CBotVar* right) override;
bool Hs(CBotVar* left, CBotVar* right) override;
bool Eq(CBotVar* left, CBotVar* right) override;
bool Ne(CBotVar* left, CBotVar* right) override;
bool Save1State(FILE* pf) override;
protected:
virtual const std::string GetDebugName() override { return "CBotExprLitChar"; }
virtual std::string GetDebugData() override;
private:
//! The value.
std::string m_val;
uint32_t m_valchar = 0;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -23,6 +23,8 @@
#include "CBot/CBotVar/CBotVar.h"
#include <cmath>
namespace CBot
{
@ -41,9 +43,9 @@ bool CBotExprLitNan::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", CBotTypInt);
CBotVar* var = CBotVar::Create("", CBotTypFloat);
var->SetInit(CBotVar::InitType::IS_NAN); // nan
var->SetValFloat(nanf(""));
pile->SetVar(var); // put on the stack
return pj->Return(pile); // forward below
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,199 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "CBot/CBotInstr/CBotExprLitNum.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
#include "CBot/CBotVar/CBotVar.h"
#include "CBot/CBotUtils.h"
#include <limits>
#include <sstream>
namespace CBot
{
template <>
CBotExprLitNum<int>::CBotExprLitNum(int val) : m_numtype(CBotTypInt), m_value(val)
{
}
template <>
CBotExprLitNum<long>::CBotExprLitNum(long val) : m_numtype(CBotTypLong), m_value(val)
{
}
template <>
CBotExprLitNum<float>::CBotExprLitNum(float val) : m_numtype(CBotTypFloat), m_value(val)
{
}
template <>
CBotExprLitNum<double>::CBotExprLitNum(double val) : m_numtype(CBotTypDouble), m_value(val)
{
}
template <typename T>
CBotExprLitNum<T>::~CBotExprLitNum()
{
}
CBotInstr* CompileExprLitNum(CBotToken* &p, CBotCStack* pStack)
{
CBotCStack* pStk = pStack->TokenStack();
const auto& s = p->GetString();
CBotInstr* inst = nullptr;
CBotType numtype = CBotTypInt;
if (p->GetType() == TokenTypDef)
{
inst = new CBotExprLitNum<int>(static_cast<int>(p->GetKeywordId()));
}
else
{
if (s.find('.') != std::string::npos || ( s.find('x') == std::string::npos && ( s.find_first_of("eE") != std::string::npos ) ))
{
double val = GetNumFloat(s);
if (val > static_cast<double>(std::numeric_limits<float>::max()))
{
numtype = CBotTypDouble;
inst = new CBotExprLitNum<double>(val);
}
else
{
numtype = CBotTypFloat;
inst = new CBotExprLitNum<float>(static_cast<float>(val));
}
}
else
{
long val = GetNumInt(s);
if (val > std::numeric_limits<int>::max())
{
numtype = CBotTypLong;
inst = new CBotExprLitNum<long>(val);
}
else
{
inst = new CBotExprLitNum<int>(static_cast<int>(val));
}
}
}
inst->SetToken(p);
if (pStk->NextToken(p))
{
CBotVar* var = CBotVar::Create("", numtype);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
delete inst;
return pStack->Return(nullptr, pStk);
}
CBotInstr* CompileSizeOf(CBotToken* &p, CBotCStack* pStack)
{
CBotToken* pp = p;
if (!IsOfType(p, TokenTypVar)) return nullptr;
if (pp->GetString() == "sizeof" && IsOfType(p, ID_OPENPAR))
{
CBotCStack* pStk = pStack->TokenStack();
int value;
if (IsOfType(p, ID_BYTE)) value = sizeof(signed char);
else if (IsOfType(p, ID_SHORT)) value = sizeof(short);
else if (IsOfType(p, ID_CHAR)) value = sizeof(uint32_t);
else if (IsOfType(p, ID_INT)) value = sizeof(int);
else if (IsOfType(p, ID_LONG)) value = sizeof(long);
else if (IsOfType(p, ID_FLOAT)) value = sizeof(float);
else if (IsOfType(p, ID_DOUBLE)) value = sizeof(double);
else
{
p = pp;
return pStack->Return(nullptr, pStk);
}
if (IsOfType(p, ID_CLOSEPAR))
{
auto inst = new CBotExprLitNum<int>(value);
inst->SetToken(pp);
CBotVar* var = CBotVar::Create("", CBotTypInt);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
pStk->SetError(CBotErrClosePar, p->GetStart());
return pStack->Return(nullptr, pStk);
}
p = pp;
return nullptr;
}
template <typename T>
bool CBotExprLitNum<T>::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", m_numtype);
if (m_token.GetType() == TokenTypDef)
{
var->SetValInt(m_value, m_token.GetString());
}
else
{
*var = m_value;
}
pile->SetVar(var); // place on the stack
return pj->Return(pile); // it's ok
}
template <typename T>
void CBotExprLitNum<T>::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}
template <typename T>
std::string CBotExprLitNum<T>::GetDebugData()
{
std::stringstream ss;
switch (m_numtype)
{
case CBotTypInt : ss << "(int) "; break;
case CBotTypLong : ss << "(long) "; break;
case CBotTypFloat : ss << "(float) "; break;
case CBotTypDouble: ss << "(double) "; break;
default: assert(false);
}
ss << m_value;
return ss.str();
}
} // namespace CBot

View File

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

View File

@ -0,0 +1,207 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "CBot/CBotInstr/CBotExprLitString.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
#include "CBot/CBotVar/CBotVar.h"
#include <stdexcept>
namespace CBot
{
////////////////////////////////////////////////////////////////////////////////
CBotExprLitString::CBotExprLitString()
{
}
////////////////////////////////////////////////////////////////////////////////
CBotExprLitString::~CBotExprLitString()
{
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotExprLitString::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotCStack* pStk = pStack->TokenStack();
const auto& s = p->GetString();
auto it = s.cbegin();
if (++it != s.cend())
{
int pos = p->GetStart();
std::string valstring = "";
while (it != s.cend() && *it != '\"')
{
++pos;
if (*it != '\\') // not escape sequence ?
{
valstring += *(it++);
continue;
}
if (++it == s.cend()) break;
pStk->SetStartError(pos);
if (CharInList(*it, "01234567")) // octal
{
std::string octal = "";
for (int i = 0; i < 3; i++)
{
if (!CharInList(*it, "01234567")) break;
++pos;
octal += *it;
if (++it == s.cend()) break;
}
unsigned int val = std::stoi(octal, nullptr, 8);
if (val <= 255)
{
valstring.push_back(val);
continue;
}
pStk->SetError(CBotErrOctalRange, pos + 1);
}
else
{
++pos;
unsigned char c = *(it++);
if (c == '\"' || c == '\'' || c == '\\') valstring += c;
else if (c == 'a') valstring += '\a'; // alert bell
else if (c == 'b') valstring += '\b'; // backspace
else if (c == 'f') valstring += '\f'; // form feed
else if (c == 'n') valstring += '\n'; // new line
else if (c == 'r') valstring += '\r'; // carriage return
else if (c == 't') valstring += '\t'; // horizontal tab
else if (c == 'v') valstring += '\v'; // vertical tab
else if (c == 'x' || c == 'u' || c == 'U') // hex or unicode
{
if (it != s.cend())
{
std::string hex = "";
bool isHexCode = (c == 'x');
size_t maxlen = (c == 'u') ? 4 : 8;
for (size_t i = 0; isHexCode || i < maxlen; i++)
{
if (!CharInList(*it, "0123456789ABCDEFabcdef")) break;
++pos;
hex += *it;
if (++it == s.cend()) break;
}
if (!hex.empty())
{
unsigned int val = 0;
try
{
val = std::stoi(hex, nullptr, 16);
}
catch (const std::out_of_range& e)
{
pStk->SetError(CBotErrHexRange, pos + 1);
}
if (pStk->IsOk())
{
if (isHexCode) // hexadecimal
{
if (val <= 255)
{
valstring.push_back(val);
continue;
}
pStk->SetError(CBotErrHexRange, pos + 1);
}
else if (maxlen == hex.length()) // unicode character
{
if (val < 0xD800 || (0xDFFF < val && val < 0x110000))
{
valstring += CodePointToUTF8(val);
continue;
}
pStk->SetError(CBotErrUnicodeName, pos + 1);
}
}
}
}
pStk->SetError(CBotErrHexDigits, pos + 1);
}
else
pStk->SetError(CBotErrBadEscape, pos + 1); // unknown escape code
}
if (!pStk->IsOk()) break;
}
if (it == s.cend() || *it != '\"')
pStk->SetError(CBotErrEndQuote, p);
if (pStk->IsOk())
{
CBotExprLitString* inst = new CBotExprLitString();
inst->m_valstring.swap(valstring);
inst->SetToken(p);
p = p->GetNext();
CBotVar* var = CBotVar::Create("", CBotTypString);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
}
pStk->SetError(CBotErrEndQuote, p);
return pStack->Return(nullptr, pStk);
}
////////////////////////////////////////////////////////////////////////////////
bool CBotExprLitString::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", CBotTypString);
var->SetValString(m_valstring);
pile->SetVar(var); // put on the stack
return pj->Return(pile);
}
////////////////////////////////////////////////////////////////////////////////
void CBotExprLitString::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}
std::string CBotExprLitString::GetDebugData()
{
return m_token.GetString();
}
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -58,6 +58,9 @@ public:
protected:
virtual const std::string GetDebugName() override { return "CBotExprLitString"; }
virtual std::string GetDebugData() override;
private:
std::string m_valstring = "";
};
} // namespace CBot

View File

@ -0,0 +1,209 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include <sstream>
#include "CBot/CBotInstr/CBotExprRetVar.h"
#include "CBot/CBotInstr/CBotExpression.h"
#include "CBot/CBotInstr/CBotInstrMethode.h"
#include "CBot/CBotInstr/CBotIndexExpr.h"
#include "CBot/CBotInstr/CBotFieldExpr.h"
#include "CBot/CBotStack.h"
namespace CBot
{
////////////////////////////////////////////////////////////////////////////////
CBotExprRetVar::CBotExprRetVar()
{
}
////////////////////////////////////////////////////////////////////////////////
CBotExprRetVar::~CBotExprRetVar()
{
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotExprRetVar::Compile(CBotToken*& p, CBotCStack* pStack, bool bMethodsOnly)
{
if (p->GetType() == ID_DOT)
{
CBotVar* var = pStack->GetVar();
if (var == nullptr) return nullptr;
CBotCStack* pStk = pStack->TokenStack();
CBotInstr* inst = new CBotExprRetVar();
while (true)
{
pStk->SetStartError(p->GetStart());
if (var->GetType() == CBotTypArrayPointer)
{
if (bMethodsOnly) goto err;
if (IsOfType( p, ID_OPBRK ))
{
CBotIndexExpr* i = new CBotIndexExpr();
i->m_expr = CBotExpression::Compile(p, pStk);
inst->AddNext3(i);
var = var->GetItem(0,true);
if (i->m_expr == nullptr || pStk->GetType() != CBotTypInt)
{
pStk->SetError(CBotErrBadIndex, p->GetStart());
goto err;
}
if (!pStk->IsOk() || !IsOfType( p, ID_CLBRK ))
{
pStk->SetError(CBotErrCloseIndex, p->GetStart());
goto err;
}
continue;
}
}
if (var->GetType(CBotVar::GetTypeMode::CLASS_AS_POINTER) == CBotTypPointer)
{
if (IsOfType(p, ID_DOT))
{
CBotToken* pp = p;
if (p->GetType() == TokenTypVar)
{
if (p->GetNext()->GetType() == ID_OPENPAR)
{
CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var, bMethodsOnly);
if (!pStk->IsOk()) goto err;
inst->AddNext3(i);
return pStack->Return(inst, pStk);
}
else if (bMethodsOnly)
{
p = p->GetPrev();
goto err;
}
else
{
CBotFieldExpr* i = new CBotFieldExpr();
i->SetToken(pp);
inst->AddNext3(i);
CBotVar* preVar = var;
var = var->GetItem(p->GetString());
if (var != nullptr)
{
i->SetUniqNum(var->GetUniqNum());
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var))
{
pStk->SetError(CBotErrPrivate, pp);
goto err;
}
}
}
if (var != nullptr)
{
p = p->GetNext();
continue;
}
pStk->SetError(CBotErrUndefItem, p);
goto err;
}
pStk->SetError(CBotErrUndefClass, p);
goto err;
}
}
break;
}
pStk->SetCopyVar(var);
if (pStk->IsOk()) return pStack->Return(inst, pStk);
pStk->SetError(CBotErrUndefVar, p);
err:
delete inst;
return pStack->Return(nullptr, pStk);
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotExprRetVar::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack();
CBotStack* pile1 = pile;
CBotVar* pVar;
if (pile1->GetState() == 0)
{
pVar = pj->GetVar();
pVar->Update(pj->GetUserPtr());
if (pVar->GetType(CBotVar::GetTypeMode::CLASS_AS_POINTER) == CBotTypNullPointer)
{
pile1->SetError(CBotErrNull, &m_token);
return pj->Return(pile1);
}
if ( !m_next3->ExecuteVar(pVar, pile, &m_token, true, false) )
return false;
if (pVar)
pile1->SetCopyVar(pVar);
else
return pj->Return(pile1);
pile1->IncState();
}
pVar = pile1->GetVar();
if (pVar == nullptr)
{
return pj->Return(pile1);
}
if (pVar->IsUndefined())
{
pile1->SetError(CBotErrNotInit, &m_token);
return pj->Return(pile1);
}
return pj->Return(pile1);
}
////////////////////////////////////////////////////////////////////////////////
void CBotExprRetVar::RestoreState(CBotStack* &pj, bool bMain)
{
if (!bMain) return;
CBotStack* pile = pj->RestoreStack();
if ( pile == nullptr ) return;
if (pile->GetState() == 0)
m_next3->RestoreStateVar(pile, bMain);
}
std::string CBotExprRetVar::GetDebugData()
{
std::stringstream ss;
ss << m_token.GetString() << "func(...).something" << std::endl;
return ss.str();
}
} // namespace CBot

View File

@ -0,0 +1,63 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "CBot/CBotInstr/CBotInstr.h"
namespace CBot
{
/**
* \brief Access a member/element of the variable on the stack
*
*
*
*/
class CBotExprRetVar : public CBotInstr
{
public:
CBotExprRetVar();
~CBotExprRetVar();
static CBotInstr* Compile(CBotToken*& p, CBotCStack* pStack, bool bMethodsOnly = false);
/*!
* \brief Execute
* \param pj
* \return
*/
bool Execute(CBotStack* &pj) override;
/*!
* \brief RestoreState
* \param pj
* \param bMain
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
protected:
virtual const std::string GetDebugName() override { return "CBotExprRetVar"; }
virtual std::string GetDebugData() override;
private:
};
} // namespace CBot

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -34,12 +34,13 @@ public:
~CBotExprUnaire();
/*!
* \brief Compile
* \param p
* \param pStack
* \return
* \brief Compile an expression with a unary operator
* \param p[in, out] Pointer to first token of the expression, will be updated to point to first token after the expression
* \param pStack Current compilation stack frame
* \param bLiteral If true, compiles only literal expressions Ex: ~11, -4.0, !false, not true
* \return The compiled instruction or nullptr
*/
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLiteral = false, bool bConstExpr = false);
/*!
* \brief Execute

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -44,7 +44,7 @@ CBotExprVar::~CBotExprVar()
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::ProtectionLevel privat)
CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, bool bCheckReadOnly)
{
// CBotToken* pDebut = p;
CBotCStack* pStk = pStack->TokenStack();
@ -67,8 +67,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
if (ident > 0 && ident < 9000)
{
if ( var->IsPrivate(privat) &&
!pStk->GetProgram()->m_bCompileClass)
if (CBotFieldExpr::CheckProtectionError(pStk, nullptr, var, bCheckReadOnly))
{
pStk->SetError(CBotErrPrivate, p);
goto err;
@ -77,6 +76,8 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
// This is an element of the current class
// ads the equivalent of this. before
CBotToken token("this");
// invisible 'this.' highlights member token on error
token.SetPos(p->GetStart(), p->GetEnd());
inst->SetToken(&token);
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // identificator for this
@ -123,6 +124,8 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
{
if (p->GetNext()->GetType() == ID_OPENPAR) // a method call?
{
if (bCheckReadOnly) goto err; // don't allow increment a method call "++"
CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var);
if (!pStk->IsOk()) goto err;
inst->AddNext3(i); // added after
@ -133,12 +136,12 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
CBotFieldExpr* i = new CBotFieldExpr(); // new element
i->SetToken(pp); // keeps the name of the token
inst->AddNext3(i); // add after
CBotVar* preVar = var;
var = var->GetItem(p->GetString()); // get item correspondent
if (var != nullptr)
{
i->SetUniqNum(var->GetUniqNum());
if ( var->IsPrivate() &&
!pStk->GetProgram()->m_bCompileClass)
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var, bCheckReadOnly))
{
pStk->SetError(CBotErrPrivate, pp);
goto err;
@ -195,6 +198,8 @@ CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack)
// this is an element of the current class
// adds the equivalent of this. before
// invisible 'this.' highlights member token on error
pthis.SetPos(pp->GetStart(), pp->GetEnd());
inst->SetToken(&pthis);
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // ident for this

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -40,14 +40,13 @@ public:
~CBotExprVar();
/*!
* \brief Compile
* \param p
* \param pStack
* \param privat
* \brief Compile an expression of a variable, possibly chained with index operators and/or dot operators
* \param p[in, out] Pointer to first token of the expression, will be updated to point to first token after the expression
* \param pStack Current compilation stack frame
* \param bCheckReadOnly True for operations that would modify the value of the variable
* \return
*/
static CBotInstr* Compile(CBotToken*& p, CBotCStack* pStack,
CBotVar::ProtectionLevel privat = CBotVar::ProtectionLevel::Protected);
static CBotInstr* Compile(CBotToken*& p, CBotCStack* pStack, bool bCheckReadOnly = false);
/*!
* \brief CompileMethode
@ -81,6 +80,8 @@ public:
*/
bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep);
using CBotInstr::ExecuteVar;
/*!
* \brief RestoreStateVar Fetch variable at runtime.
* \param pj

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -71,6 +71,13 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack)
return nullptr;
}
if ( p->GetType() == ID_SEP )
{
pStack->SetError(CBotErrNoExpression, p);
delete inst;
return nullptr;
}
inst->m_rightop = CBotExpression::Compile(p, pStack);
if (inst->m_rightop == nullptr)
{
@ -118,13 +125,13 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack)
break;
case ID_ASSADD:
if (type2.Eq(CBotTypBoolean) ||
type2.Eq(CBotTypPointer) ) type2 = -1; // numbers and strings
type2.GetType() > CBotTypString ) type2.SetType(-1); // numbers and strings
break;
case ID_ASSSUB:
case ID_ASSMUL:
case ID_ASSDIV:
case ID_ASSMODULO:
if (type2.GetType() >= CBotTypBoolean) type2 = -1; // numbers only
if (type2.GetType() >= CBotTypBoolean) type2.SetType(-1); // numbers only
break;
}
@ -179,6 +186,18 @@ bool CBotExpression::Execute(CBotStack* &pj)
if ( pile2->GetState()==0)
{
if (m_rightop && !m_rightop->Execute(pile2)) return false; // initial value // interrupted?
if (m_rightop)
{
CBotVar* var = pile1->GetVar();
CBotVar* value = pile2->GetVar();
if (var->GetType() == CBotTypString && value->GetType() != CBotTypString)
{
CBotVar* newVal = CBotVar::Create("", var->GetTypResult());
value->Update(pj->GetUserPtr());
newVal->SetValString(value->GetValString());
pile2->SetVar(newVal);
}
}
pile2->IncState();
}
@ -187,12 +206,6 @@ bool CBotExpression::Execute(CBotStack* &pj)
if (m_token.GetType() != ID_ASS)
{
pVar = pile1->GetVar(); // recovers if interrupted
initKind = pVar->GetInit();
if (initKind == CBotVar::InitType::IS_NAN)
{
pile2->SetError(CBotErrNan, m_leftop->GetToken());
return pj->Return(pile2);
}
result = CBotVar::Create("", pVar->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -134,4 +134,56 @@ std::string CBotFieldExpr::GetDebugData()
return ss.str();
}
////////////////////////////////////////////////////////////////////////////////
bool CBotFieldExpr::CheckProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar, bool bCheckReadOnly)
{
CBotVar::ProtectionLevel varPriv = pVar->GetPrivate();
if (bCheckReadOnly && varPriv == CBotVar::ProtectionLevel::ReadOnly)
return true;
if (varPriv == CBotVar::ProtectionLevel::Public) return false;
std::string prevName = (pPrev == nullptr) ? "" : pPrev->GetName();
// implicit 'this.'var, this.var, or super.var
if (pPrev == nullptr || prevName == "this" || prevName == "super") // member of the current class
{
if (varPriv == CBotVar::ProtectionLevel::Private) // var is private ?
{
CBotToken token("this");
CBotVar* pThis = pStack->FindVar(token);
CBotClass* pClass = pThis->GetClass(); // the current class
CBotVar* pVarList = pClass->GetVar();
int ident = pVar->GetUniqNum();
// check if var is inherited from a parent class
if (pVarList == nullptr || ident < pVarList->GetUniqNum())
return true;
}
}
else // any other context
{
if (pVar->IsPrivate()) // var is protected or private ?
{
CBotToken token("this");
CBotVar* pThis = pStack->FindVar(token);
if (pThis == nullptr) return true; // inside a function ?
if (pThis->GetType() != CBotTypPointer) return true;
CBotClass* pClass = pThis->GetClass(); // the current class
if (!pClass->IsChildOf(pPrev->GetClass())) // var is member of some other class ?
return true;
if (varPriv == CBotVar::ProtectionLevel::Private && // private member of a parent class
pClass != pPrev->GetClass()) return true;
}
}
return false;
}
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -65,6 +65,20 @@ public:
*/
void RestoreStateVar(CBotStack* &pj, bool bMain) override;
/*!
* \brief Check if access to a variable is allowed or not depending on public/private/protected setting
*
* If this function returns true, the caller is responsible for failing the compilation with ::CBotErrPrivate error.
* This function doesn't set the error flag itself.
*
* \param pStack Current compilation stack frame
* \param pPrev Class instance which variable to check is part of, or nullptr when compiler inserts 'this.' before
* \param pVar Variable to check
* \param bCheckReadOnly True for operations that would modify the value of the variable
* \return true if pVar is inaccessible in the current context, false if access should be allowed
*/
static bool CheckProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar, bool bCheckReadOnly = false);
protected:
virtual const std::string GetDebugName() override { return "CBotFieldExpr"; }
virtual std::string GetDebugData() override;

View File

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

View File

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

View File

@ -0,0 +1,370 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "CBot/CBotInstr/CBotInstr.h"
#include <set>
namespace CBot
{
/**
* \brief A function declaration in the code
*
* Examples:
* \code
* void test() { ... }
* void test(int a, float b) { ... }
* int test(int a, float b, string c) { ... }
* public bool test(int a, float b, string c, SomeClass d) { ... }
* extern void test() { ... }
* void classname::test() { ... }
* \endcode
*/
class CBotFunction : public CBotInstr
{
public:
CBotFunction();
~CBotFunction();
/*!
* \brief Compile Compiles a new function
* \param p
* \param pStack
* \param pFunc
* \param bLocal allows of the declaration of parameters on the same level
* as the elements belonging to the class for methods.
* \return
*/
static CBotFunction* Compile(CBotToken* &p,
CBotCStack* pStack,
CBotFunction* pFunc,
bool bLocal = true);
/*!
* \brief Pre-compile a new function
* \param p[in, out] Pointer to first token of the function, will be updated to point to first token after the function definition
* \param pStack Compile stack
* \param pClass If this is a class method, pointer to class this function is part of, otherwise nullptr
*
* This function is used to find the beginning and end of function definition.
*
* If any errors in the code are detected, this function will set the error on compile stack and return nullptr.
*
* \return Precompiled function, or nullptr in case of error
*/
static CBotFunction* Compile1(CBotToken* &p,
CBotCStack* pStack,
CBotClass* pClass);
/*!
* \brief Execute
* \param ppVars
* \param pj
* \param pInstance
* \return
*/
bool Execute(CBotVar** ppVars,
CBotStack* &pj,
CBotVar* pInstance = nullptr);
using CBotInstr::Execute;
/*!
* \brief RestoreState
* \param ppVars
* \param pj
* \param pInstance
*/
void RestoreState(CBotVar** ppVars,
CBotStack* &pj,
CBotVar* pInstance = nullptr);
using CBotInstr::RestoreState;
/*!
* \brief Compile a function call
*
* See FindLocalOrPublic for more detailed explanation
*
* \param name Name of the function
* \param ppVars List of function arguments
* \param nIdent[in, out] Unique identifier of the function
* \param program The current program, to search for functions.
* \return Type returned by the function or error code
* \see FindLocalOrPublic
*/
static CBotTypResult CompileCall(const std::string &name, CBotVar** ppVars,
long &nIdent, CBotProgram* program);
/*!
* \brief Finds a local or public function
*
* <p>First, it looks for a function according to its unique identifier.<br>
* If the identifier is not found, looks by name and parameters.
*
* \param localFunctionList Linked list of local functions to search in, can be null
* \param nIdent[in, out] Unique identifier of the function
* \param name Name of the function
* \param ppVars List of function arguments
* \param TypeOrError Type returned by the function or error code
* \param baseProg Initial program, for context of the object/bot
* \return Pointer to found CBotFunction instance, or nullptr in case of no match or ambiguity (see TypeOrError for error code)
*/
static CBotFunction* FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
CBotVar** ppVars, CBotTypResult &TypeOrError, CBotProgram* baseProg);
/*!
* \brief Find all functions that match the name and arguments.
* \param functionList List of functions to search, can be empty.
* \param name Name of the function to find.
* \param ppVars Arguments to compare with parameters.
* \param TypeOrError Contains a CBotError when no useable function has been found.
* \param funcMap Container for suitable functions and their signature values.
* \param pClass Pointer to class when searching for methods.
*/
static void SearchList(const std::list<CBotFunction*>& functionList,
const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass = nullptr);
/*!
* \brief Find all public functions that match the name and arguments.
* \param name Name of the function to find.
* \param ppVars Arguments to compare with parameters.
* \param TypeOrError Contains a CBotError when no useable function has been found.
* \param funcMap Container for suitable functions and their signature values.
* \param pClass Pointer to class when searching for methods.
*/
static void SearchPublic(const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass = nullptr);
/*!
* \brief Find the function with the lowest signature value. If there is more
* than one of the same signature value, TypeOrError is set to CBotErrAmbiguousCall.
* \param funcMap List of functions and their signature values, can be empty.
* \param[out] nIdent Unique identifier of the function.
* \param TypeOrError Type returned by the function or error code.
* \return Pointer to the function with the lowest signature or nullptr.
*/
static CBotFunction* BestFunction(std::map<CBotFunction*, int>& funcMap,
long& nIdent, CBotTypResult& TypeOrError);
/*!
* \brief DoCall Fait un appel à une fonction.
* \param program
* \param localFunctionList
* \param nIdent
* \param name
* \param ppVars
* \param pStack
* \param pToken
* \return
*/
static int DoCall(CBotProgram* program, const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken);
/*!
* \brief RestoreCall
* \param localFunctionList
* \param nIdent
* \param name
* \param ppVars
* \param pStack
*/
static void RestoreCall(const std::list<CBotFunction*>& localFunctionList,
long &nIdent, const std::string &name, CBotVar** ppVars, CBotStack* pStack);
/*!
* \brief Find a method matching the name and arguments.
* \param name Name of the method to find.
* \param ppVars Arguments to compare with parameters.
* \param[out] nIdent Unique identifier of the method.
* \param pStack Current compilation stack frame.
* \param pClass Pointer to the class.
* \return The return type for the method or a CBotError.
*/
static CBotTypResult CompileMethodCall(const std::string& name, CBotVar** ppVars,
long& nIdent, CBotCStack* pStack, CBotClass* pClass);
/*!
* \brief Find a method by its unique identifier or by name and parameters.
* \param[in,out] nIdent Unique identifier of the method.
* \param name Name of the method to find.
* \param ppVars Arguments to compare with parameters.
* \param TypeOrError The return type for the method or a CBotError.
* \param pClass Pointer to the class.
* \param program The current program, to search for out-of-class methods.
* \return Pointer to the method that best matches the given arguments or nullptr.
*/
static CBotFunction* FindMethod(long& nIdent, const std::string& name,
CBotVar** ppVars, CBotTypResult& TypeOrError,
CBotClass* pClass, CBotProgram* program);
/*!
* \brief DoCall Makes call of a method
* \param nIdent
* \param name
* \param pThis
* \param ppVars
* \param pStack
* \param pToken
* \param pClass
* \return
*/
static int DoCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass);
/*!
* \brief RestoreCall
* \param nIdent
* \param name
* \param pThis
* \param ppVars
* \param pStack
* \param pClass
* \return Returns true if the method call was restored.
*/
static bool RestoreCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass);
/*!
* \brief CheckParam See if the "signature" of parameters is identical.
* \param pParam
* \return
*/
bool CheckParam(CBotDefParam* pParam);
/*!
* \brief AddPublic
* \param pfunc
*/
static void AddPublic(CBotFunction* pfunc);
/*!
* \brief GetName
* \return
*/
const std::string& GetName();
/*!
* \brief GetParams
* \return
*/
std::string GetParams();
/*!
* \brief Get the name of the class for a method.
* \return The name of a class or empty string if it's not a method.
*/
const std::string& GetClassName() const;
/*!
* \brief IsPublic
* \return
*/
bool IsPublic();
/*!
* \brief Check if a method is protected.
* \return true if a method was compiled with "protected" keyword.
*/
bool IsProtected() const;
/*!
* \brief Check if a method is private.
* \return true if a method was compiled with "private" keyword.
*/
bool IsPrivate() const;
/*!
* \brief IsExtern
* \return
*/
bool IsExtern();
/*!
* \brief GetPosition
* \param start
* \param stop
* \param modestart
* \param modestop
* \return
*/
bool GetPosition(int& start, int& stop,
CBotGet modestart,
CBotGet modestop);
/*!
* \brief Check if the function has a return statment that will execute.
* \return true if a return statment was found.
*/
bool HasReturn() override;
protected:
virtual const std::string GetDebugName() override { return "CBotFunction"; }
virtual std::string GetDebugData() override;
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
private:
friend class CBotDebug;
long m_nFuncIdent;
//! Synchronized method.
bool m_bSynchro;
//! Parameter list.
CBotDefParam* m_param;
//! The instruction block.
CBotInstr* m_block;
//! If returns CBotTypClass.
CBotToken m_retToken;
//! Complete type of the result.
CBotTypResult m_retTyp;
//! Public function.
bool m_bPublic;
//! Protected method.
bool m_bProtect = false;
//! Private method.
bool m_bPrivate = false;
//! Extern function.
bool m_bExtern;
//! Name of the class we are part of
std::string m_MasterClass;
//! Token of the class we are part of
CBotToken m_classToken;
CBotProgram* m_pProg;
//! For the position of the word "extern".
CBotToken m_extern;
CBotToken m_openpar;
CBotToken m_closepar;
CBotToken m_openblk;
CBotToken m_closeblk;
//! List of public functions
static std::set<CBotFunction*> m_publicFunctions;
friend class CBotProgram;
friend class CBotClass;
friend class CBotCStack;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -163,6 +163,15 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
}
}
bool CBotIf::HasReturn()
{
if (m_block != nullptr && m_blockElse != nullptr)
{
if (m_block->HasReturn() && m_blockElse->HasReturn()) return true;
}
return CBotInstr::HasReturn(); // check next block or instruction
}
std::map<std::string, CBotInstr*> CBotIf::GetDebugLinks()
{
auto links = CBotInstr::GetDebugLinks();

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -56,6 +56,14 @@ public:
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
/**
* \brief Check 'if' and 'else' for return statements.
* Returns true when 'if' and 'else' have return statements,
* if not, the next block or instruction is checked.
* \return true if a return statement is found.
*/
bool HasReturn() override;
protected:
virtual const std::string GetDebugName() override { return "CBotIf"; }
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -69,6 +69,7 @@ private:
CBotInstr* m_expr;
friend class CBotLeftExpr;
friend class CBotExprVar;
friend class CBotExprRetVar;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -30,6 +30,7 @@
#include "CBot/CBotInstr/CBotExpression.h"
#include "CBot/CBotInstr/CBotFor.h"
#include "CBot/CBotInstr/CBotIf.h"
#include "CBot/CBotInstr/CBotRepeat.h"
#include "CBot/CBotInstr/CBotReturn.h"
#include "CBot/CBotInstr/CBotSwitch.h"
#include "CBot/CBotInstr/CBotThrow.h"
@ -176,7 +177,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
{
type = pp->GetType();
// Allow only instructions that accept a label
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, 0))
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0))
{
pStack->SetError(CBotErrLabel, pp->GetStart());
return nullptr;
@ -195,6 +196,9 @@ 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);
@ -208,10 +212,15 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
case ID_THROW:
return CBotThrow::Compile(p, pStack);
case ID_BYTE:
case ID_SHORT:
case ID_CHAR:
case ID_INT:
case ID_LONG:
return CBotDefInt::Compile(p, pStack);
case ID_FLOAT:
case ID_DOUBLE:
return CBotDefFloat::Compile(p, pStack);
case ID_STRING:
@ -312,13 +321,6 @@ void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain)
assert(0); // dad do not know, see the girls
}
////////////////////////////////////////////////////////////////////////////////
bool CBotInstr::CompCase(CBotStack* &pj, int val)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first)
{
if (IsOfType(p, ID_OPBRK))
@ -359,6 +361,12 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes
return nullptr;
}
bool CBotInstr::HasReturn()
{
if (m_next != nullptr) return m_next->HasReturn();
return false; // end of the list
}
std::map<std::string, CBotInstr*> CBotInstr::GetDebugLinks()
{
return {

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -38,7 +38,7 @@ class CBotDebug;
* \endcode
* the following structure is generated:
* \dot
* # Generated using the CBot_compile_graph tool
* # Generated using the CBot-CompileGraph tool
* # and slightly modified
* digraph {
* start [label=<START> shape=box3d color=cyan]
@ -191,17 +191,6 @@ public:
virtual void RestoreStateVar(CBotStack* &pile,
bool bMain);
/**
* \brief CompCase This routine is defined only for the subclass CBotCase
* this allows to make the call on all instructions CompCase to see if it's
* a case to the desired value..
* \param pj
* \param val
* \return
*/
virtual bool CompCase(CBotStack* &pj,
int val);
/**
* \brief SetToken Set the token corresponding to the instruction.
* \param p
@ -281,6 +270,12 @@ public:
*/
static bool ChkLvl(const std::string& label, int type);
/**
* \brief Check a list of instructions for a return statement.
* \return true if a return statement was found.
*/
virtual bool HasReturn();
protected:
friend class CBotDebug;
/**

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -18,7 +18,8 @@
*/
#include "CBot/CBotInstr/CBotInstrCall.h"
#include "CBot/CBotInstr/CBotExpression.h"
#include "CBot/CBotInstr/CBotExprRetVar.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotStack.h"
@ -35,6 +36,7 @@ namespace CBot
CBotInstrCall::CBotInstrCall()
{
m_parameters = nullptr;
m_exprRetVar = nullptr;
m_nFuncIdent = 0;
}
@ -42,67 +44,32 @@ CBotInstrCall::CBotInstrCall()
CBotInstrCall::~CBotInstrCall()
{
delete m_parameters;
delete m_exprRetVar;
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotVar* ppVars[1000];
int i = 0;
CBotToken* pp = p;
p = p->GetNext();
pStack->SetStartError(p->GetStart());
CBotCStack* pile = pStack;
if ( IsOfType(p, ID_OPENPAR) )
if (p->GetType() == ID_OPENPAR)
{
int start, end;
CBotVar* ppVars[1000];
CBotInstrCall* inst = new CBotInstrCall();
inst->SetToken(pp);
// compile la list of parameters
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
{
start = p->GetStart();
pile = pile->TokenStack(); // keeps the results on the stack
inst->m_parameters = CompileParams(p, pStack, ppVars);
CBotInstr* param = CBotExpression::Compile(p, pile);
end = p->GetStart();
if (inst->m_parameters == nullptr ) inst->m_parameters = param;
else inst->m_parameters->AddNext(param); // constructs the list
if ( !pile->IsOk() )
if ( !pStack->IsOk() )
{
delete inst;
return pStack->Return(nullptr, pile);
}
if ( param != nullptr )
{
if ( pile->GetTypResult().Eq(99) )
{
delete pStack->TokenStack();
pStack->SetError(CBotErrVoid, p->GetStart());
delete inst;
return nullptr;
}
ppVars[i] = pile->GetVar();
ppVars[i]->GetToken()->SetPos(start, end);
i++;
if (IsOfType(p, ID_COMMA)) continue; // skips the comma
if (IsOfType(p, ID_CLOSEPAR)) break;
}
pStack->SetError(CBotErrClosePar, p->GetStart());
delete pStack->TokenStack();
delete inst;
return nullptr;
}
ppVars[i] = nullptr;
// the routine is known?
// CBotClass* pClass = nullptr;
@ -111,12 +78,12 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
{
// if (pVar2!=nullptr) pp = pVar2->RetToken();
pStack->SetError( static_cast<CBotError>(inst->m_typRes.GetType()), pp );
delete pStack->TokenStack();
pStack->DeleteNext();
delete inst;
return nullptr;
}
delete pStack->TokenStack();
pStack->DeleteNext();
if ( inst->m_typRes.GetType() > 0 )
{
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
@ -124,10 +91,21 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
}
else pStack->SetVar(nullptr); // routine returns void
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack)))
{
inst->m_exprRetVar->SetToken(&inst->m_token);
pStack->DeleteNext();
}
if ( !pStack->IsOk() )
{
delete inst;
return nullptr;
}
return inst;
}
p = pp;
delete pStack->TokenStack();
pStack->DeleteNext();
return nullptr;
}
@ -138,6 +116,17 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this);
if ( pile->StackOver() ) return pj->Return( pile );
CBotStack* pile3 = nullptr;
if (m_exprRetVar != nullptr) // func().member
{
pile3 = pile->AddStack2();
if (pile3->GetState() == 1) // function call is done?
{
if (!m_exprRetVar->Execute(pile3)) return false;
return pj->Return(pile3);
}
}
// CBotStack* pile1 = pile;
int i = 0;
@ -149,6 +138,7 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
if ( p != nullptr) while ( true )
{
pile = pile->AddStack(); // place on the stack for the results
if (pile->StackOver()) return pj->Return(pile);
if ( pile->GetState() == 0 )
{
if (!p->Execute(pile)) return false; // interrupted here?
@ -165,6 +155,14 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
if ( !pile2->ExecuteCall(m_nFuncIdent, GetToken(), ppVars, m_typRes)) return false; // interrupt
if (m_exprRetVar != nullptr) // func().member
{
pile3->SetCopyVar( pile2->GetVar() ); // copy the result
pile2->SetVar(nullptr);
pile3->SetState(1); // set call is done
return false; // go back to the top ^^^
}
return pj->Return(pile2); // release the entire stack
}
@ -176,6 +174,16 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this);
if ( pile == nullptr ) return;
if (m_exprRetVar != nullptr) // func().member
{
CBotStack* pile3 = pile->AddStack2();
if (pile3->GetState() == 1) // function call is done?
{
m_exprRetVar->RestoreState(pile3, bMain);
return;
}
}
// CBotStack* pile1 = pile;
int i = 0;

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -69,6 +69,10 @@ private:
CBotTypResult m_typRes;
//! Id of a function.
long m_nFuncIdent;
//! Instruction to return a member of the returned object.
CBotInstr* m_exprRetVar;
friend class CBotDebug;
};

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -20,6 +20,7 @@
#include <sstream>
#include "CBot/CBotInstr/CBotInstrMethode.h"
#include "CBot/CBotInstr/CBotExprRetVar.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotStack.h"
@ -35,6 +36,7 @@ namespace CBot
CBotInstrMethode::CBotInstrMethode()
{
m_parameters = nullptr;
m_exprRetVar = nullptr;
m_MethodeIdent = 0;
}
@ -42,10 +44,11 @@ CBotInstrMethode::CBotInstrMethode()
CBotInstrMethode::~CBotInstrMethode()
{
delete m_parameters;
delete m_exprRetVar;
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* var)
CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* var, bool bMethodChain)
{
CBotInstrMethode* inst = new CBotInstrMethode();
inst->SetToken(p); // corresponding token
@ -63,11 +66,11 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
if (pStack->IsOk())
{
inst->m_thisIdent = var->GetUniqNum();
CBotClass* pClass = var->GetClass(); // pointer to the class
inst->m_className = pClass->GetName(); // name of the class
CBotTypResult r = pClass->CompileMethode(inst->m_methodName, var, ppVars,
pStack, inst->m_MethodeIdent);
delete pStack->TokenStack(); // release parameters on the stack
CBotTypResult r = pClass->CompileMethode(pp, var, ppVars, pStack, inst->m_MethodeIdent);
pStack->DeleteNext(); // release parameters on the stack
inst->m_typRes = r;
if (inst->m_typRes.GetType() > 20)
@ -86,6 +89,16 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
}
pStack->SetVar(pResult);
}
else pStack->SetVar(nullptr);
pp = p;
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack, bMethodChain)))
{
inst->m_exprRetVar->SetToken(pp);
pStack->DeleteNext();
}
if ( pStack->IsOk() )
return inst;
}
delete inst;
@ -103,6 +116,19 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
if (pVar->GetPointer() == nullptr)
{
pj->SetError(CBotErrNull, prevToken);
return pj->Return(pile1);
}
CBotStack* pile3 = nullptr;
if (m_exprRetVar != nullptr) // .func().member
{
pile3 = pile1->AddStack2();
if (pile3->GetState() == 1)
{
if (!m_exprRetVar->Execute(pile3)) return false;
pVar = nullptr;
return pj->Return(pile3);
}
}
if (pile1->IfStep()) return false;
@ -119,7 +145,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
pThis->SetName("this");
pThis->SetUniqNum(-2);
pile1->AddVar(pThis);
pile1->SetVar(pThis);
pile1->IncState();
}
int i = 0;
@ -138,25 +164,30 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
}
ppVars[i++] = pile2->GetVar(); // construct the list of pointers
pile2 = pile2->AddStack(); // space on the stack for the result
if (pile2->StackOver()) return pj->Return(pile2);
p = p->GetNext();
if ( p == nullptr) break;
}
ppVars[i] = nullptr;
CBotClass* pClass = CBotClass::Find(m_className);
CBotVar* pThis = pile1->FindVar(-2, false);
CBotVar* pResult = nullptr;
if (m_typRes.GetType() > 0) pResult = CBotVar::Create("", m_typRes);
if (m_typRes.Eq(CBotTypClass))
{
pResult->SetClass(m_typRes.GetClass());
}
CBotVar* pRes = pResult;
CBotVar* pThis = pile1->GetVar();
CBotClass* pClass;
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_methodName,
pThis, ppVars,
pResult, pile2, GetToken())) return false;
if (pRes != pResult) delete pRes;
if (m_thisIdent == -3) // super.method()
pClass = CBotClass::Find(m_className);
else
pClass = pThis->GetClass();
if ( !pClass->ExecuteMethode(m_MethodeIdent, pThis, ppVars, m_typRes, pile2, GetToken())) return false;
if (m_exprRetVar != nullptr) // .func().member
{
pile3->SetCopyVar( pile2->GetVar() );
pile2->SetVar(nullptr);
pile3->SetState(1); // set call is done
pVar = nullptr;
return false; // go back to the top ^^^
}
pVar = nullptr; // does not return value for this
return pj->Return(pile2); // release the entire stack
@ -171,10 +202,23 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain)
CBotStack* pile1 = pile->RestoreStack(this); // place for the copy of This
if (pile1 == nullptr) return;
if (m_exprRetVar != nullptr) // .func().member
{
CBotStack* pile3 = pile1->AddStack2();
if (pile3->GetState() == 1) // function call is done?
{
m_exprRetVar->RestoreState(pile3, bMain);
return;
}
}
CBotStack* pile2 = pile1->RestoreStack(); // and for the parameters coming
if (pile2 == nullptr) return;
CBotVar* pThis = pile1->FindVar("this");
CBotVar* pThis = pile1->GetVar();
assert(pThis != nullptr); // see fix for issues #256 & #436
pThis->SetUniqNum(-2);
int i = 0;
@ -200,13 +244,18 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain)
}
ppVars[i] = nullptr;
CBotClass* pClass = CBotClass::Find(m_className);
CBotClass* pClass;
if (m_thisIdent == -3) // super.method()
pClass = CBotClass::Find(m_className);
else
pClass = pThis->GetClass();
// CBotVar* pResult = nullptr;
// CBotVar* pRes = pResult;
pClass->RestoreMethode(m_MethodeIdent, m_methodName,
pThis, ppVars, pile2);
pClass->RestoreMethode(m_MethodeIdent, &m_token, pThis, ppVars, pile2);
}
////////////////////////////////////////////////////////////////////////////////
@ -226,7 +275,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
// Test.Action (Test = Other);
// Action must act on the value before test = Other!
pThis->SetName("this");
pile1->AddVar(pThis);
pile1->SetVar(pThis);
pile1->IncState();
}
int i = 0;
@ -249,26 +298,20 @@ bool CBotInstrMethode::Execute(CBotStack* &pj)
}
ppVars[i] = nullptr;
CBotClass* pClass = CBotClass::Find(m_className);
CBotVar* pThis = pile1->FindVar("this");
CBotVar* pResult = nullptr;
if (m_typRes.GetType()>0) pResult = CBotVar::Create("", m_typRes);
if (m_typRes.Eq(CBotTypClass))
{
pResult->SetClass(m_typRes.GetClass());
}
CBotVar* pRes = pResult;
CBotVar* pThis = pile1->GetVar();
CBotClass* pClass;
if ( !pClass->ExecuteMethode(m_MethodeIdent, m_methodName,
pThis, ppVars,
pResult, pile2, GetToken())) return false; // interupted
if (m_thisIdent == -3) // super.method()
pClass = CBotClass::Find(m_className);
else
pClass = pThis->GetClass();
if ( !pClass->ExecuteMethode(m_MethodeIdent, pThis, ppVars, m_typRes, pile2, GetToken())) return false; // interupted
// set the new value of this in place of the old variable
CBotVar* old = pile1->FindVar(m_token, false);
old->Copy(pThis, false);
if (pRes != pResult) delete pRes;
return pj->Return(pile2); // release the entire stack
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -38,9 +38,10 @@ public:
* \param p
* \param pStack
* \param pVar
* \param bMethodChain If true, allows chaining methods only
* \return
*/
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar);
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar, bool bMethodChain = false);
/*!
* \brief Execute
@ -83,6 +84,12 @@ private:
long m_MethodeIdent;
//! Name of the class.
std::string m_className;
//! Variable ID
long m_thisIdent;
//! Instruction to return a member of the returned object.
CBotInstr* m_exprRetVar;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -65,7 +65,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars)
{
if (pile->GetTypResult().Eq(99))
{
delete pStack->TokenStack();
pStack->DeleteNext();
pStack->SetError(CBotErrVoid, p->GetStart());
return nullptr;
}
@ -78,7 +78,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars)
}
pStack->SetError(CBotErrClosePar, p->GetStart());
delete pStack->TokenStack();
pStack->DeleteNext();
return nullptr;
}
}
@ -97,9 +97,9 @@ bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op)
if (max == 99) return false; // result is void?
// special case for strin concatenation
if (op == ID_ADD && max >= CBotTypString) return true;
if (op == ID_ASSADD && max >= CBotTypString) return true;
if (op == ID_ASS && t1 == CBotTypString) return true;
if (op == ID_ADD && t1 == CBotTypString) return true;
if (op == ID_ASSADD && t2 == CBotTypString) return true;
if (op == ID_ASS && t2 == CBotTypString) return true;
if (max >= CBotTypBoolean)
{
@ -129,6 +129,13 @@ bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op)
return true;
}
if (op == ID_ASR || op == ID_SR || op == ID_SL ||
op == ID_ASSOR || op == ID_ASSSL || op == ID_ASSSR ||
op == ID_ASSAND || op == ID_ASSXOR || op == ID_ASSASR)
{
if (max > CBotTypLong) return false;
}
type1.SetType(max);
type2.SetType(max);
return true;
@ -149,12 +156,20 @@ bool TypesCompatibles(const CBotTypResult& type1, const CBotTypResult& type2)
if (max >= CBotTypBoolean)
{
if (t1 == CBotTypPointer && t2 == CBotTypNullPointer) return true;
if (t2 != t1) return false;
if (max == CBotTypPointer)
{
CBotClass* c1 = type1.GetClass();
CBotClass* c2 = type2.GetClass();
return c2->IsChildOf(c1);
}
if (max == CBotTypArrayPointer)
return TypesCompatibles(type1.GetTypElem(), type2.GetTypElem());
if (max == CBotTypClass || max == CBotTypPointer)
if (max == CBotTypClass)
return type1.GetClass() == type2.GetClass() ;
return true ;

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -39,7 +39,13 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars);
/*!
* \brief TypeCompatible Check if two results are consistent to make an
* operation.
* operation. TypeCompatible is used in two ways:
* For non-assignment operations: see CBotTwoOpExpr::Compile
* TypeCompatible( leftType, rightType, opType )
* For assignment or compound assignment operations (it's reversed):
* see CBotReturn::Compile & CBotExpression::Compile
* TypeCompatible( valueType, varType, opType )
* \param type1
* \param type2
* \param op

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -64,8 +64,7 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
inst->m_nIdent = var->GetUniqNum();
if (inst->m_nIdent > 0 && inst->m_nIdent < 9000)
{
if ( var->IsPrivate(CBotVar::ProtectionLevel::ReadOnly) &&
!pStk->GetProgram()->m_bCompileClass)
if (CBotFieldExpr::CheckProtectionError(pStk, nullptr, var, true))
{
pStk->SetError(CBotErrPrivate, p);
goto err;
@ -73,6 +72,8 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
// this is an element of the current class
// adds the equivalent of this. before
CBotToken pthis("this");
// invisible 'this.' highlights member token on error
pthis.SetPos(p->GetStart(), p->GetEnd());
inst->SetToken(&pthis);
inst->m_nIdent = -2; // indent for this
@ -125,11 +126,11 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
if (p->GetType() == TokenTypVar) // must be a name
{
CBotVar* preVar = var;
var = var->GetItem(p->GetString()); // get item correspondent
if (var != nullptr)
{
if ( var->IsPrivate(CBotVar::ProtectionLevel::ReadOnly) &&
!pStk->GetProgram()->m_bCompileClass)
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var, true))
{
pStk->SetError(CBotErrPrivate, pp);
goto err;
@ -182,14 +183,17 @@ bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array)
if (t2.Eq(CBotTypPointer))
{
CBotClass* c1 = t1.GetClass();
CBotClass* c2 = t2.GetClass();
CBotClass* c2 = var2->GetClass();
if ( !c2->IsChildOf(c1))
{
CBotToken* pt = &m_token;
pile->SetError(CBotErrBadType1, pt);
return pj->Return(pile); // operation performed
}
var1->SetVal(var2); // set pointer
var1->SetType(t1); // keep pointer type
}
else
var1->SetVal(var2); // do assignment
}
pile->SetCopyVar(var1); // replace the stack with the copy of the variable

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -61,6 +61,8 @@ public:
*/
bool Execute(CBotStack* &pStack, CBotStack* array);
using CBotInstr::Execute;
/*!
* \brief ExecuteVar Fetch a variable during compilation.
* \param pVar
@ -69,6 +71,8 @@ public:
*/
bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) override;
using CBotInstr::ExecuteVar;
/*!
* \brief ExecuteVar Fetch the variable at runtume.
* \param pVar

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -64,6 +64,12 @@ bool CBotLeftExprVar::Execute(CBotStack* &pj)
CBotVar* var2 = pj->GetVar(); // Initial value on the stack
if (var2 != nullptr)
{
if (m_typevar.Eq(CBotTypString) && var2->GetType() != CBotTypString)
{
var2->Update(pj->GetUserPtr());
var1->SetValString(var2->GetValString());
return true;
}
var1->SetVal(var2); // Set the value
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -51,12 +51,13 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
CBotToken* pp = p;
if (IsOfType( p, ID_NULL ))
if (IsOfType( p, ID_NULL ) || (IsOfType(p, ID_OPBLK) && IsOfType(p, ID_CLBLK)))
{
CBotInstr* inst = new CBotExprLitNull();
inst->SetToken(pp);
return pStack->Return(inst, pStk); // ok with empty element
}
p = pp;
CBotListArray* inst = new CBotListArray();
@ -65,25 +66,45 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
// each element takes the one after the other
if (type.Eq( CBotTypArrayPointer ))
{
type = type.GetTypElem();
pStk->SetStartError(p->GetStart());
if (nullptr == ( inst->m_expr = CBotListArray::Compile( p, pStk, type ) ))
if (nullptr == ( inst->m_expr = CBotListArray::Compile( p, pStk, type.GetTypElem() ) ))
{
if (pStk->IsOk())
{
inst->m_expr = CBotTwoOpExpr::Compile(p, pStk);
if (inst->m_expr == nullptr || !pStk->GetTypResult().Compare(type)) // compatible type ?
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
}
}
}
while (IsOfType( p, ID_COMMA )) // other elements?
{
pStk->SetStartError(p->GetStart());
CBotInstr* i = CBotListArray::Compile(p, pStk, type);
if (nullptr == i)
CBotInstr* i = nullptr;
if (nullptr == ( i = CBotListArray::Compile(p, pStk, type.GetTypElem() ) ))
{
if (pStk->IsOk())
{
i = CBotTwoOpExpr::Compile(p, pStk);
if (i == nullptr || !pStk->GetTypResult().Compare(type)) // compatible type ?
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
}
}
}
inst->m_expr->AddNext3(i);
inst->m_expr->AddNext3b(i);
if ( p->GetType() == ID_COMMA ) continue;
if ( p->GetType() == ID_CLBLK ) break;
pStk->SetError(CBotErrClosePar, p);
goto error;
}
}
else
@ -93,9 +114,10 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
{
goto error;
}
CBotVar* pv = pStk->GetVar(); // result of the expression
if (pv == nullptr || !TypesCompatibles( type, pv->GetTypResult())) // compatible type?
CBotTypResult valType = pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC);
if (!TypeCompatible(valType, type, ID_ASS) )
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
@ -111,14 +133,20 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
goto error;
}
CBotVar* pv = pStk->GetVar(); // result of the expression
CBotTypResult valType = pStk->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC);
if (pv == nullptr || !TypesCompatibles( type, pv->GetTypResult())) // compatible type?
if (!TypeCompatible(valType, type, ID_ASS) )
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
}
inst->m_expr->AddNext3(i);
inst->m_expr->AddNext3b(i);
if (p->GetType() == ID_COMMA) continue;
if (p->GetType() == ID_CLBLK) break;
pStk->SetError(CBotErrClosePar, p);
goto error;
}
}
@ -146,7 +174,7 @@ bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar)
int n = 0;
for (; p != nullptr ; n++, p = p->GetNext3())
for (; p != nullptr ; n++, p = p->GetNext3b())
{
if (pile1->GetState() > n) continue;
@ -157,9 +185,12 @@ bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar)
pj->SetError(CBotErrOutArray, p->GetToken());
return false;
}
CBotTypResult type = pVar2->GetTypResult();
if (!p->Execute(pile1, pVar2)) return false; // evaluate expression
if (type.Eq(CBotTypPointer)) pVar2->SetType(type); // keep pointer type
pile1->IncState();
}
@ -178,7 +209,7 @@ void CBotListArray::RestoreState(CBotStack* &pj, bool bMain)
int state = pile->GetState();
while(state-- > 0) p = p->GetNext3() ;
while(state-- > 0) p = p->GetNext3b() ;
p->RestoreState(pile, bMain); // size calculation //interrupted!
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -62,7 +62,7 @@ protected:
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
private:
//! An expression for an element others are linked with CBotInstr :: m_next3;
//! An expression for an element others are linked with CBotInstr :: m_next3b;
CBotInstr* m_expr;
};

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -52,7 +52,7 @@ CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal
if (IsOfType(p, ID_SEP)) continue; // empty statement ignored
if (p->GetType() == ID_CLBLK) break;
if (IsOfType(p, 0))
if (p->GetType() == TokenTypNone)
{
pStack->SetError(CBotErrCloseBlock, p->GetStart());
delete inst;
@ -117,6 +117,12 @@ void CBotListInstr::RestoreState(CBotStack* &pj, bool bMain)
if (p != nullptr) p->RestoreState(pile, true);
}
bool CBotListInstr::HasReturn()
{
if (m_instr != nullptr && m_instr->HasReturn()) return true;
return CBotInstr::HasReturn(); // check next block or instruction
}
std::map<std::string, CBotInstr*> CBotListInstr::GetDebugLinks()
{
auto links = CBotInstr::GetDebugLinks();

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -56,6 +56,13 @@ public:
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
/**
* \brief Check this block of instructions for a return statement.
* If not found, the next block or instruction is checked.
* \return true if a return statement was found.
*/
bool HasReturn() override;
protected:
virtual const std::string GetDebugName() override { return "CBotListInstr"; }
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
@ -24,6 +24,7 @@
#include "CBot/CBotCStack.h"
#include "CBot/CBotClass.h"
#include "CBot/CBotInstr/CBotExprRetVar.h"
#include "CBot/CBotInstr/CBotInstrUtils.h"
#include "CBot/CBotVar/CBotVar.h"
@ -35,12 +36,15 @@ namespace CBot
CBotNew::CBotNew()
{
m_parameters = nullptr;
m_exprRetVar = nullptr;
m_nMethodeIdent = 0;
}
////////////////////////////////////////////////////////////////////////////////
CBotNew::~CBotNew()
{
delete m_parameters;
delete m_exprRetVar;
}
////////////////////////////////////////////////////////////////////////////////
@ -50,7 +54,11 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
if (!IsOfType(p, ID_NEW)) return nullptr;
// verifies that the token is a class name
if (p->GetType() != TokenTypVar) return nullptr;
if (p->GetType() != TokenTypVar)
{
pStack->SetError(CBotErrBadNew, p);
return nullptr;
}
CBotClass* pClass = CBotClass::Find(p);
if (pClass == nullptr)
@ -78,8 +86,8 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
if (!pStk->IsOk()) goto error;
// constructor exist?
CBotTypResult r = pClass->CompileMethode(pClass->GetName(), pVar, ppVars, pStk, inst->m_nMethodeIdent);
delete pStk->TokenStack(); // release extra stack
CBotTypResult r = pClass->CompileMethode(&inst->m_vartoken, pVar, ppVars, pStk, inst->m_nMethodeIdent);
pStk->DeleteNext(); // release extra stack
int typ = r.GetType();
// if there is no constructor, and no parameters either, it's ok
@ -101,6 +109,16 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
// makes pointer to the object on the stack
pStk->SetVar(pVar);
pp = p;
// chained method ?
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
{
inst->m_exprRetVar->SetToken(pp);
pStk->DeleteNext();
}
if (pStack->IsOk())
return pStack->Return(inst, pStk);
}
error:
@ -113,6 +131,16 @@ bool CBotNew::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this); //main stack
if (m_exprRetVar != nullptr) // new Class().method()
{
if (pile->GetState() == 2)
{
CBotStack* pile3 = pile->AddStack();
if (!m_exprRetVar->Execute(pile3)) return false;
return pj->Return(pile3);
}
}
if (pile->IfStep()) return false;
CBotStack* pile1 = pj->AddStack2(); //secondary stack
@ -161,6 +189,7 @@ bool CBotNew::Execute(CBotStack* &pj)
if (p != nullptr) while ( true)
{
pile2 = pile2->AddStack(); // space on the stack for the result
if (pile2->StackOver()) return pj->Return(pile2);
if (pile2->GetState() == 0)
{
if (!p->Execute(pile2)) return false; // interrupted here?
@ -172,16 +201,21 @@ bool CBotNew::Execute(CBotStack* &pj)
}
ppVars[i] = nullptr;
// create a variable for the result
CBotVar* pResult = nullptr; // constructos still void
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
pThis, ppVars,
pResult, pile2, GetToken())) return false; // interrupt
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pThis, ppVars, CBotTypResult(CBotTypVoid), pile2, &m_vartoken)) return false; // interrupt
pThis->ConstructorSet(); // indicates that the constructor has been called
}
if (m_exprRetVar != nullptr) // new Class().method()
{
pile->AddStack()->Delete(); // release pile2 stack
CBotStack* pile3 = pile->AddStack(); // add new stack
pile3->SetCopyVar(pThis); // copy the pointer (from pile1)
pile1->Delete(); // release secondary stack(pile1)
pile->SetState(2);
return false; // go back to the top ^^^
}
return pj->Return(pile1); // passes below
}
@ -193,6 +227,16 @@ void CBotNew::RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this); //primary stack
if (pile == nullptr) return;
if (m_exprRetVar != nullptr) // new Class().method()
{
if (pile->GetState() == 2)
{
CBotStack* pile3 = pile->RestoreStack();
m_exprRetVar->RestoreState(pile3, bMain);
return;
}
}
CBotStack* pile1 = pj->AddStack2(); //secondary stack
CBotToken* pt = &m_vartoken;
@ -239,8 +283,7 @@ void CBotNew::RestoreState(CBotStack* &pj, bool bMain)
}
ppVars[i] = nullptr;
pClass->RestoreMethode(m_nMethodeIdent, m_vartoken.GetString(), pThis,
ppVars, pile2) ; // interrupt here!
pClass->RestoreMethode(m_nMethodeIdent, &m_vartoken, pThis, ppVars, pile2); // interrupt here!
}
}

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