Compare commits

...

724 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
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
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
Tim Göttlicher e9a153df14 Smoother shadows on OpenGL 2.1 2019-04-28 01:27:12 +02: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
Fiftytwo 723c552783 Add Heavy and Amphibious trainer bots 2018-12-23 07:04:06 +01: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
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
Fiftytwo caf58c8ab8 Merge branch 'dev' of https://github.com/colobot/colobot into dev 2018-05-07 21:48:48 +02: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
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
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
840 changed files with 35105 additions and 61184 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

12
.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
@ -39,6 +40,13 @@ 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-2018, 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-2018, 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 = CBotFunction::CompileCall(m_prog->GetFunctions(), 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,16 +387,19 @@ 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;
for (CBotFunction* pp : m_prog->GetFunctions())
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;
@ -381,8 +408,11 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
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;
@ -392,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-2018, 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-2018, 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
@ -315,7 +315,7 @@ CBotTypResult CBotClass::CompileMethode(CBotToken* name,
// find the methods declared by user
r = CBotFunction::CompileCall(m_pMethod, name->GetString(), ppParams, nIdent);
r = CBotFunction::CompileMethodCall(name->GetString(), ppParams, nIdent, pStack, this);
if ( r.Eq(CBotErrUndefCall) && m_parent != nullptr )
return m_parent->CompileMethode(name, pThis, ppParams, pStack, nIdent);
return r;
@ -332,7 +332,7 @@ bool CBotClass::ExecuteMethode(long& nIdent,
int ret = m_externalMethods->DoCall(pToken, pThis, ppParams, pStack, pResultType);
if (ret >= 0) return ret;
ret = CBotFunction::DoCall(m_pMethod, nIdent, pToken->GetString(), 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)
@ -355,7 +355,7 @@ void CBotClass::RestoreMethode(long& nIdent,
CBotClass* pClass = this;
while (pClass != nullptr)
{
bool ok = CBotFunction::RestoreCall(pClass->m_pMethod, nIdent, name->GetString(), pThis, ppParams, pStack, pClass);
bool ok = CBotFunction::RestoreCall(nIdent, name->GetString(), pThis, ppParams, pStack, pClass);
if (ok) return;
pClass = pClass->m_parent;
}
@ -542,6 +542,11 @@ void CBotClass::DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pSta
}
}
const std::list<CBotFunction*>& CBotClass::GetFunctions() const
{
return m_pMethod;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
@ -600,8 +605,8 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
// return a method precompiled in pass 1
CBotCStack* pStk = pStack->TokenStack(nullptr, true);
CBotDefParam* params = CBotDefParam::Compile(p, pStk );
delete pStk;
std::list<CBotFunction*>::iterator pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, &params](CBotFunction* x)
pStack->DeleteNext();
auto pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, &params](CBotFunction* x)
{
return x->GetName() == pp && x->CheckParam( params );
});
@ -609,45 +614,8 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
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());
pcopy->SetPrivate(pv->GetPrivate());
pile->AddVar(pcopy);
pv = pv->GetNext();
}
my = my->m_parent;
}
// compiles a method
p = pBase;
CBotFunction* f =
@ -658,7 +626,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
f->m_pProg = pStack->GetProgram();
f->m_bSynchro = bSynchro;
}
pStack->Return(nullptr, pile);
pStack->DeleteNext();
}
return pStack->IsOk();

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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
@ -303,6 +303,12 @@ public:
*/
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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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,11 +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
{
@ -53,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")

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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,10 +64,8 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
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)
{
@ -96,7 +94,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
prevHasDefault = true;
}
else pStack->SetError(CBotErrNoExpression, p);
delete pStk;
pStack->DeleteNext();
}
else
if (prevHasDefault) pStack->SetError(CBotErrDefaultValue, p->GetPrev());
@ -105,7 +103,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
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);
@ -140,6 +137,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
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;
@ -151,13 +149,12 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr))
{
assert(p->m_expr != nullptr);
useDefault = true;
if (!p->m_expr->Execute(pile)) return false; // interupt here
pVar = pile->GetVar();
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];

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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
@ -100,6 +100,7 @@ enum TokenId
ID_STATIC,
ID_PROTECTED,
ID_PRIVATE,
ID_REPEAT,
ID_INT,
ID_FLOAT,
ID_BOOLEAN,

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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)
CBotVar* pVar = MakeListVars(ppVar, true);
// if this is a method call we need to use AddStack()
CBotStack* pile = (thisVar != nullptr) ? pStack->AddStack() : pStack->AddStackExternalCall(pt);
// creates a variable to the result
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
if (pile->GetState() == 0) // the first time?
{
// lists the parameters depending on the contents of the stack
CBotVar* pVar = MakeListVars(ppVar, true);
pile->SetVar(pVar);
pile->SetVar(pVar);
CBotStack* pile2 = pile->AddStack();
pile2->SetVar(pResult);
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,8 +168,7 @@ 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;
}
@ -187,8 +191,8 @@ CBotTypResult CBotExternalCallClass::Compile(CBotVar* thisVar, CBotVar* args, vo
bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
{
if (pStack->IsCallFinished()) return true;
CBotStack* pile = pStack->AddStackExternalCall(this);
assert(thisVar != nullptr);
CBotStack* pile = pStack->AddStack();
CBotVar* args = pile->GetVar();
CBotStack* pile2 = pile->AddStack();
@ -207,9 +211,8 @@ bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
return false;
}
if (result != nullptr) pStack->SetCopyVar(result);
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-2018, 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-2018, 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
@ -59,7 +59,7 @@ static bool ReadBinary(std::istream &istr, T &value)
while (true) // unsigned LEB128
{
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
if (shift < sizeof(T) * 8 - 1)
if (shift < sizeof(T) * 8)
value |= static_cast<T>(chr & 0x7F) << shift;
shift += 7;
if ((chr & 0x80) == 0) break;
@ -183,42 +183,66 @@ bool ReadLong(std::istream &istr, long &l)
bool WriteFloat(std::ostream &ostr, float f)
{
union {float fValue; unsigned int iValue;} u;
union TypeConverter
{
float fValue;
uint32_t iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
u.fValue = f;
return WriteBinary<unsigned int>(ostr, u.iValue);
return WriteBinary<uint32_t>(ostr, u.iValue);
}
bool ReadFloat(std::istream &istr, float &f)
{
union {float fValue; unsigned int iValue;} u;
union TypeConverter
{
float fValue;
uint32_t iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
if (!ReadBinary<unsigned int>(istr, u.iValue)) return false;
if (!ReadBinary<uint32_t>(istr, u.iValue)) return false;
f = u.fValue;
return true;
}
bool WriteDouble(std::ostream &ostr, double d)
{
union {double dValue; unsigned long iValue;} u;
union TypeConverter
{
double dValue;
uint64_t iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
u.dValue = d;
return WriteBinary<unsigned long>(ostr, u.iValue);
return WriteBinary<uint64_t>(ostr, u.iValue);
}
bool ReadDouble(std::istream &istr, double &d)
{
union {double dValue; unsigned long iValue;} u;
union TypeConverter
{
double dValue;
uint64_t iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
if (!ReadBinary<unsigned long>(istr, u.iValue)) return false;
if (!ReadBinary<uint64_t>(istr, u.iValue)) return false;
d = u.dValue;
return true;
}
@ -318,7 +342,11 @@ bool WriteStream(std::ostream &ostr, std::istream& istr)
if (!WriteLong(ostr, size)) return false;
if (!istr.seekg(0, istr.beg)) return false;
if (!(ostr << istr.rdbuf())) return false;
while (size > 0)
{
size -= 1;
if (!ostr.put(istr.get())) return false;
}
return true;
}
@ -331,7 +359,7 @@ bool ReadStream(std::istream& istr, std::ostream &ostr)
while (length-- > 0)
{
if (!(ostr << istr.get())) return false;
if (!ostr.put(istr.get())) return false;
}
return true;
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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 @@
#pragma once
#include <cstdint>
#include <iostream>
#include <string>

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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
@ -135,7 +135,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
// the constructor is there?
// std::string noname;
CBotTypResult r = pClass->CompileMethode(&token, var, ppVars, pStk, inst->m_nMethodeIdent);
delete pStk->TokenStack(); // releases the supplement stack
pStk->DeleteNext(); // releases the supplement stack
int typ = r.GetType();
if (typ == CBotErrUndefCall)
@ -160,7 +160,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
{
inst->m_exprRetVar->SetToken(vartoken);
delete pStk->TokenStack();
pStk->DeleteNext();
}
pStk->SetVar(nullptr);
@ -360,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?

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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 <cstdint>
namespace CBot
{

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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,9 @@ class CBotExprLitNum : public CBotInstr
{
public:
CBotExprLitNum(T val);
// 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"); };
~CBotExprLitNum();
/*!

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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,8 @@
#include "CBot/CBotVar/CBotVar.h"
#include <stdexcept>
namespace CBot
{

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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
@ -206,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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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
@ -76,6 +76,18 @@ bool CBotFunction::IsPublic()
return m_bPublic;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotFunction::IsProtected() const
{
return m_bProtect;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotFunction::IsPrivate() const
{
return m_bPrivate;
}
////////////////////////////////////////////////////////////////////////////////
bool CBotFunction::IsExtern()
{
@ -129,21 +141,17 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
{
CBotToken* pp;
CBotFunction* func = finput;
if ( func == nullptr ) func = new CBotFunction();
assert(func != nullptr); // a pre-compiled function is required
CBotCStack* pStk = pStack->TokenStack(p, bLocal);
// func->m_nFuncIdent = CBotVar::NextUniqNum();
while (true)
{
if ( IsOfType(p, ID_PUBLIC) )
{
func->m_bPublic = true;
continue;
}
if (IsOfType(p, ID_PRIVATE)) break;
if (IsOfType(p, ID_PROTECTED)) break;
if (IsOfType(p, ID_PUBLIC)) continue;
pp = p;
if ( IsOfType(p, ID_EXTERN) )
if (IsOfType(p, ID_EXTERN))
{
func->m_extern = *pp; // for the position of the word "extern"
func->m_bExtern = true;
@ -183,10 +191,23 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
goto bad;
}
// pp = p;
pp = p;
func->m_token = *p;
if (!IsOfType(p, TokenTypVar)) goto bad;
// check if the class has a method like this
if (pClass->CheckCall(pStack->GetProgram(), func->m_param, pp))
{
pStk->SetStartError(func->m_classToken.GetStart());
pStk->SetError(CBotErrRedefFunc, pp->GetEnd());
goto bad;
}
// check if a constructor has return type void
if (func->GetName() == pClass->GetName() && !func->m_retTyp.Eq(CBotTypVoid))
{
pp = &(func->m_retToken);
pStk->SetError(CBotErrFuncNotVoid, pp);
goto bad;
}
}
func->m_openpar = *p;
delete func->m_param;
@ -198,28 +219,13 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
if (!func->m_MasterClass.empty())
{
// return "this" known
CBotVar* pThis = CBotVar::Create("this", CBotTypResult( CBotTypClass, func->m_MasterClass ));
pThis->SetInit(CBotVar::InitType::IS_POINTER);
// pThis->SetUniqNum(func->m_nThisIdent = -2); //CBotVar::NextUniqNum() will not
pThis->SetUniqNum(-2);
pStk->AddVar(pThis);
CBotClass* pClass = CBotClass::Find(func->m_MasterClass);
// initialize variables acording to This
// only saves the pointer to the first,
// the rest is chained
CBotVar* pv = pThis->GetItemList();
// int num = 1;
while (pv != nullptr)
{
CBotVar* pcopy = CBotVar::Create(pv);
// pcopy->SetInit(2);
pcopy->Copy(pv);
pcopy->SetPrivate(pv->GetPrivate());
// pcopy->SetUniqNum(pv->GetUniqNum()); //num++);
pStk->AddVar(pcopy);
pv = pv->GetNext();
}
pStk->CreateVarThis(pClass);
pStk->CreateVarSuper(pClass->GetParent());
bool bConstructor = (func->GetName() == func->m_MasterClass);
pStk->CreateMemberVars(pClass, !bConstructor);
}
// and compiles the following instruction block
@ -242,7 +248,6 @@ bad:
pStk->SetError(CBotErrNoFunc, p);
}
pStk->SetError(CBotErrNoType, p);
if ( finput == nullptr ) delete func;
return pStack->ReturnFunc(nullptr, pStk);
}
@ -254,14 +259,30 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
CBotCStack* pStk = pStack->TokenStack(p, true);
CBotToken* pPriv = p;
while (true)
{
if ( IsOfType(p, ID_PUBLIC) )
if (!func->m_bPublic) // don't repeat 'public'
{
// func->m_bPublic = true; // will be done in two passes
continue;
pPriv = p;
if (IsOfType(p, ID_PRIVATE))
{
func->m_bPrivate = true;
break;
}
if (IsOfType(p, ID_PROTECTED))
{
func->m_bProtect = true;
break;
}
if (IsOfType(p, ID_PUBLIC))
{
func->m_bPublic = true;
continue;
}
}
if ( IsOfType(p, ID_EXTERN) )
if (!func->m_bExtern && IsOfType(p, ID_EXTERN))
{
func->m_bExtern = true;
continue;
@ -297,12 +318,21 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
if (!IsOfType(p, TokenTypVar)) goto bad;
}
else if (pClass == nullptr) // not method in a class ?
{
if (func->m_bPrivate || func->m_bProtect) // not allowed for regular functions
{
pStk->SetError(CBotErrNoType, pPriv);
goto bad;
}
}
CBotToken* openPar = p;
func->m_param = CBotDefParam::Compile(p, pStk); // compile parameters
if (pStk->IsOk() && pClass != nullptr) // method in a class
{
func->m_MasterClass = pClass->GetName();
// check if a constructor has return type void
if (func->GetName() == pClass->GetName() && !func->m_retTyp.Eq(CBotTypVoid))
{
@ -331,7 +361,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
{
// looks if the function exists elsewhere
pp = &(func->m_token);
if (( pClass != nullptr || !pStack->CheckCall(pp, func->m_param)) &&
if (( pClass != nullptr || !pStack->CheckCall(pp, func->m_param, func->m_MasterClass)) &&
( pClass == nullptr || !pClass->CheckCall(pStack->GetProgram(), func->m_param, pp)) )
{
if (IsOfType(p, ID_OPBLK))
@ -415,7 +445,7 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
pile->IncState();
}
if ( !m_block->Execute(pile) )
if (!pile->GetRetVar(m_block->Execute(pile)))
{
if ( pile->GetError() < 0 )
pile->SetError( CBotNoErr );
@ -472,10 +502,10 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
}
////////////////////////////////////////////////////////////////////////////////
CBotTypResult CBotFunction::CompileCall(const std::list<CBotFunction*>& localFunctionList, const std::string &name, CBotVar** ppVars, long &nIdent)
CBotTypResult CBotFunction::CompileCall(const std::string &name, CBotVar** ppVars, long &nIdent, CBotProgram* program)
{
CBotTypResult type;
if (!FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type))
if (!FindLocalOrPublic(program->GetFunctions(), nIdent, name, ppVars, type, program))
{
// Reset the identifier to "not found" value
nIdent = 0;
@ -485,7 +515,7 @@ CBotTypResult CBotFunction::CompileCall(const std::list<CBotFunction*>& localFun
////////////////////////////////////////////////////////////////////////////////
CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
CBotVar** ppVars, CBotTypResult &TypeOrError, bool bPublic)
CBotVar** ppVars, CBotTypResult &TypeOrError, CBotProgram* baseProg)
{
TypeOrError.SetType(CBotErrUndefCall); // no routine of the name
@ -515,10 +545,39 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
std::map<CBotFunction*, int> funcMap;
for (CBotFunction* pt : localFunctionList)
CBotFunction::SearchList(localFunctionList, name, ppVars, TypeOrError, funcMap);
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap);
if (baseProg != nullptr && baseProg->m_thisVar != nullptr)
{
// find object:: functions
CBotClass* pClass = baseProg->m_thisVar->GetClass();
CBotFunction::SearchList(localFunctionList, name, ppVars, TypeOrError, funcMap, pClass);
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap, pClass);
}
return CBotFunction::BestFunction(funcMap, nIdent, TypeOrError);
}
////////////////////////////////////////////////////////////////////////////////
void CBotFunction::SearchList(const std::list<CBotFunction*>& functionList,
const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass)
{
for (CBotFunction* pt : functionList)
{
if ( pt->m_token.GetString() == name )
{
if (pClass != nullptr) // looking for a method ?
{
if (pt->m_MasterClass != pClass->GetName()) continue;
}
else // looking for a function
{
if (!pt->m_MasterClass.empty()) continue;
}
int i = 0;
int alpha = 0; // signature of parameters
// parameters are compatible?
@ -575,13 +634,26 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
funcMap.insert( std::pair<CBotFunction*, int>(pt, alpha) );
}
}
}
if ( bPublic )
////////////////////////////////////////////////////////////////////////////////
void CBotFunction::SearchPublic(const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass)
{
{
for (CBotFunction* pt : m_publicFunctions)
{
if ( pt->m_token.GetString() == name )
{
if (pClass != nullptr) // looking for a method ?
{
if (pt->m_MasterClass != pClass->GetName()) continue;
}
else // looking for a function
{
if (!pt->m_MasterClass.empty()) continue;
}
int i = 0;
int alpha = 0; // signature of parameters
// are parameters compatible ?
@ -639,7 +711,12 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
CBotFunction* CBotFunction::BestFunction(std::map<CBotFunction*, int>& funcMap,
long& nIdent, CBotTypResult& TypeOrError)
{
if ( !funcMap.empty() )
{
auto it = funcMap.begin();
@ -675,7 +752,7 @@ int CBotFunction::DoCall(CBotProgram* program, const std::list<CBotFunction*>& l
CBotFunction* pt = nullptr;
CBotProgram* baseProg = pStack->GetProgram(true);
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, baseProg);
if ( pt != nullptr )
{
@ -766,7 +843,7 @@ void CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList
CBotStack* pStk3;
CBotProgram* baseProg = pStack->GetProgram(true);
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, baseProg);
if ( pt != nullptr )
{
@ -824,13 +901,121 @@ void CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList
}
////////////////////////////////////////////////////////////////////////////////
int CBotFunction::DoCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
CBotTypResult CBotFunction::CompileMethodCall(const std::string& name, CBotVar** ppVars,
long& nIdent, CBotCStack* pStack, CBotClass* pClass)
{
nIdent = 0;
CBotTypResult type;
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pStack->GetProgram());
if (pt != nullptr)
{
CBotToken token("this");
CBotVar* pThis = pStack->FindVar(token); // for 'this' context
if (pThis == nullptr || pThis->GetType() != CBotTypPointer) // called from inside a function
{
if (pt->IsPrivate() || pt->IsProtected())
type.SetType(CBotErrPrivate);
}
else // called from inside a method
{
CBotClass* thisClass = pThis->GetClass(); // current class
CBotClass* funcClass = CBotClass::Find(pt->m_MasterClass); // class of the method
if (pt->IsPrivate() && thisClass != funcClass)
type.SetType(CBotErrPrivate);
if (pt->IsProtected() && !thisClass->IsChildOf(funcClass))
type.SetType(CBotErrPrivate);
}
}
return type;
}
////////////////////////////////////////////////////////////////////////////////
CBotFunction* CBotFunction::FindMethod(long& nIdent, const std::string& name,
CBotVar** ppVars, CBotTypResult& TypeOrError,
CBotClass* pClass, CBotProgram* program)
{
TypeOrError.SetType(CBotErrUndefCall); // no routine of the name
auto methods = pClass->GetFunctions();
if ( nIdent )
{
// search methods in the class
for (CBotFunction* pt : methods)
{
if ( pt->m_nFuncIdent == nIdent )
{
TypeOrError = pt->m_retTyp;
return pt;
}
}
bool skipPublic = false;
if (program != nullptr)
{
// search the current program
for (CBotFunction* pt : program->GetFunctions())
{
if ( pt->m_nFuncIdent == nIdent )
{
// check if the method is inherited
if ( pt->GetClassName() != pClass->GetName() )
{
skipPublic = true;
break; // break in case there is an override
}
TypeOrError = pt->m_retTyp;
return pt;
}
}
}
// search the list of public functions
if (!skipPublic)
{
for (CBotFunction* pt : m_publicFunctions)
{
if (pt->m_nFuncIdent == nIdent)
{
// check if the method is inherited, break in case there is an override
if ( pt->GetClassName() != pClass->GetName() ) break;
TypeOrError = pt->m_retTyp;
return pt;
}
}
}
}
if ( name.empty() ) return nullptr;
std::map<CBotFunction*, int> funcMap;
// search methods in the class
CBotFunction::SearchList(methods, name, ppVars, TypeOrError, funcMap, pClass);
// search the current program for methods
if (program != nullptr)
CBotFunction::SearchList(program->GetFunctions(), name, ppVars, TypeOrError, funcMap, pClass);
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap, pClass);
return CBotFunction::BestFunction(funcMap, nIdent, TypeOrError);
}
////////////////////////////////////////////////////////////////////////////////
int CBotFunction::DoCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
{
CBotTypResult type;
CBotProgram* pProgCurrent = pStack->GetProgram();
CBotFunction* pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, false);
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pProgCurrent);
if ( pt != nullptr )
{
@ -925,11 +1110,11 @@ int CBotFunction::DoCall(const std::list<CBotFunction*>& localFunctionList, long
}
////////////////////////////////////////////////////////////////////////////////
bool CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
bool CBotFunction::RestoreCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass)
{
CBotTypResult type;
CBotFunction* pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pStack->GetProgram());
if ( pt != nullptr )
{
@ -1020,6 +1205,12 @@ std::string CBotFunction::GetParams()
return params;
}
////////////////////////////////////////////////////////////////////////////////
const std::string& CBotFunction::GetClassName() const
{
return m_MasterClass;
}
////////////////////////////////////////////////////////////////////////////////
void CBotFunction::AddPublic(CBotFunction* func)
{

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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,21 +105,19 @@ public:
*
* See FindLocalOrPublic for more detailed explanation
*
* \param localFunctionList Linked list of local functions to search in, can be null
* \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::list<CBotFunction*>& localFunctionList,
const std::string &name, CBotVar** ppVars, long &nIdent);
static CBotTypResult CompileCall(const std::string &name, CBotVar** ppVars,
long &nIdent, CBotProgram* program);
/*!
* \brief Finds a local or public function
*
* <p>Finds a local or (if bPublic is true) public function to call
*
* <p>First, it looks for a function according to its unique identifier.<br>
* If the identifier is not found, looks by name and parameters.
*
@ -128,11 +126,46 @@ public:
* \param name Name of the function
* \param ppVars List of function arguments
* \param TypeOrError Type returned by the function or error code
* \param bPublic Whether to look in public functions or not
* \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, bool bPublic = true);
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.
@ -160,10 +193,34 @@ public:
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
* note: this is already on the stack, the pointer pThis is just to simplify.
* \param localFunctionList
* \param nIdent
* \param name
* \param pThis
@ -173,12 +230,11 @@ public:
* \param pClass
* \return
*/
static int DoCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
static int DoCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass);
/*!
* \brief RestoreCall
* \param localFunctionList
* \param nIdent
* \param name
* \param pThis
@ -187,7 +243,7 @@ public:
* \param pClass
* \return Returns true if the method call was restored.
*/
static bool RestoreCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
static bool RestoreCall(long &nIdent, const std::string &name, CBotVar* pThis,
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass);
/*!
@ -215,12 +271,30 @@ public:
*/
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
@ -266,6 +340,10 @@ private:
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

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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);

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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]

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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
@ -78,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);
@ -94,7 +94,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack)))
{
inst->m_exprRetVar->SetToken(&inst->m_token);
delete pStack->TokenStack();
pStack->DeleteNext();
}
if ( !pStack->IsOk() )
{
@ -105,7 +105,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
return inst;
}
p = pp;
delete pStack->TokenStack();
pStack->DeleteNext();
return nullptr;
}
@ -138,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?

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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
@ -70,7 +70,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
CBotClass* pClass = var->GetClass(); // pointer to the class
inst->m_className = pClass->GetName(); // name of the class
CBotTypResult r = pClass->CompileMethode(pp, var, ppVars, pStack, inst->m_MethodeIdent);
delete pStack->TokenStack(); // release parameters on the stack
pStack->DeleteNext(); // release parameters on the stack
inst->m_typRes = r;
if (inst->m_typRes.GetType() > 20)
@ -95,7 +95,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack, bMethodChain)))
{
inst->m_exprRetVar->SetToken(pp);
delete pStack->TokenStack();
pStack->DeleteNext();
}
if ( pStack->IsOk() )
@ -164,6 +164,7 @@ 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;
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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;
}
}

View File

@ -1,6 +1,6 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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-2018, 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
@ -87,7 +87,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
// constructor exist?
CBotTypResult r = pClass->CompileMethode(&inst->m_vartoken, pVar, ppVars, pStk, inst->m_nMethodeIdent);
delete pStk->TokenStack(); // release extra stack
pStk->DeleteNext(); // release extra stack
int typ = r.GetType();
// if there is no constructor, and no parameters either, it's ok
@ -115,7 +115,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
{
inst->m_exprRetVar->SetToken(pp);
delete pStk->TokenStack();
pStk->DeleteNext();
}
if (pStack->IsOk())
@ -189,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?

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