Skip to content

Commit 293be34

Browse files
authored
Merge branch 'master' into cheat_enable_buildings
2 parents e36a78e + 6b51676 commit 293be34

File tree

17 files changed

+158
-118
lines changed

17 files changed

+158
-118
lines changed

data/RTTR/assets/base/fonts.lst

10 MB
Binary file not shown.

data/RTTR/assets/base/languages.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ Norwegian Bokmal=nb
2121
Slovenian=sl
2222
Latin=la
2323
Portuguese=pt
24+
Chinese=zh_CN

data/RTTR/campaigns/roman/campaign.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ campaign = {
2929
maxHumanPlayers = 1,
3030
difficulty = "easy",
3131
mapFolder = "<RTTR_GAME>/DATA/MAPS",
32-
luaFolder = "<RTTR_RTTR>/campaigns/roman",
32+
luaFolder = "",
3333
maps = { "MISS200.WLD","MISS201.WLD","MISS202.WLD","MISS203.WLD","MISS204.WLD","MISS205.WLD","MISS206.WLD","MISS207.WLD","MISS208.WLD","MISS209.WLD"}
3434
}

data/RTTR/campaigns/world/campaign.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ campaign = {
2929
maxHumanPlayers= 1,
3030
difficulty = "easy",
3131
mapFolder = "<RTTR_GAME>/DATA/MAPS2",
32-
luaFolder = "<RTTR_RTTR>/CAMPAIGNS/WORLD",
32+
luaFolder = "",
3333
maps = { "EUROPE.WLD","NAMERICA.WLD","SAMERICA.WLD","GREEN.WLD","AFRICA.WLD","NASIA.WLD","SASIA.WLD","JAPAN.WLD","AUSTRA.WLD"},
3434
selectionMap = {
3535
background = {"<RTTR_GAME>/GFX/PICS/SETUP990.LBM", 0},

doc/AddingCustomCampaign.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ We will now create an example campaign `garden`.
1111

1212
## Location for adding a new campaign
1313

14-
To add a new custom campaign you have to create a new subfolder with your campaign name under `RTTR/campaigns/` in the install directory or under `<RTTR_USERDATA>/campaigns/`.
15-
`<RTTR_USERDATA>` is the placeholder for the RttR folder in your user dir, e.g. `~/.s25rttr` on Linux or "Saved Games" on Windows.
14+
To add a new custom campaign you have to create a new subfolder with your campaign name under `RTTR/campaigns/` in the installation directory or under `<RTTR_USERDATA>/campaigns/`.
15+
`<RTTR_USERDATA>` is the placeholder for the RttR folder in your user directory, e.g. `~/.s25rttr` on Linux or "Saved Games" on Windows.
1616
This subfolder will be filled with all the needed data for the campaign.
1717
We create the subfolder `RTTR/campaigns/garden` for our new example campaign.
1818

19-
2019
## Lua campaign description file
2120

2221
First we have to add a `campaign.lua` file to our campaign folder `RTTR/campaigns/garden`. This file describes the settings and needed stuff for our new campaign `garden`.
2322

24-
```
23+
```lua
2524
function getRequiredLuaVersion()
2625
return 1
2726
end
@@ -64,63 +63,70 @@ campaign = {
6463
}
6564
```
6665

67-
## Explaination of the semantic of the campaign.lua file
66+
## Explanation of the semantic of the campaign Lua file
6867

69-
The `rttr:RegisterTranslations` function is used for the possibility of providing translation support for the texts displayed in the rttr campaign selection screen. If you do not want to provide any translation you can delete this function from the lua file and write your text directly in the specific fields below.
70-
The `campaign` dict describes your campaign. The `getRequiredLuaVersion` function returns the version of the lua campaign interface.
68+
The `rttr:RegisterTranslations` function is used for the possibility of providing translation support for the texts displayed in the RttR campaign selection screen.
69+
If you do not want to provide any translation you can delete this function from the Lua file and write your text directly in the specific fields below.
70+
The `campaign` dict describes your campaign. The `getRequiredLuaVersion` function returns the version of the Lua campaign interface.
7171

7272
### Versioning
7373

74-
The lua campaign interface is versioned using a major version. Everytime a feature is added or a breaking change is made (e.g. a function is removed or changes behavior considerably) the major version is increased.
74+
The Lua campaign interface is versioned using a major version. Every time a feature is added, or a breaking change is made (e.g. a function is removed or changes behavior considerably) the major version is increased.
7575

7676
Every map script must have 1 function:
77-
getRequiredLuaVersion()
77+
`getRequiredLuaVersion()`
7878
You need to implement this and return the version your script works with. If it does not match the current version an error will be shown and the script will not be used.
7979

8080
### Explanation of the campaign table fields
8181

82-
If you want a field to be translated you have to add the translation as described above and set the variable to _"<key>". The _"..." will translate the text during application execution depending on your language settings.
82+
If you want a field to be translated you have to add the translation as described above and set the variable to `_"<key>"`. The `_"..."` will translate the text during application execution depending on your language settings.
8383

8484
1. `version`: Simple a number for versioning of the campaign
8585
2. `author`: Human readable string of the campaign creator
8686
3. `name`: The name of the campaign
87-
4. `shortDescription`: Short description of the campaign (like a head line to get a rough imagination of the campaign)
87+
4. `shortDescription`: Short description of the campaign (like a headline to get a rough imagination of the campaign)
8888
5. `longDescription`: Extended description describing the campaign in detail. Will be shown in the campaign selection screen, when the campaign is selected.
8989
6. `image`: Path to an image displayed in the campaign selection screen. You can omit this if you do no want to provide an image.
9090
7. `maxHumanPlayers`: For now this is always 1 until we support multiplayer campaigns
91-
8. `difficulty`: Difficulty of the campaign. Should be one of the valus easy, medium or hard.
92-
9. `mapFolder` and `luaFolder`: Path to the folder containing the campaign maps and associated lua files. Usually your campaign folder or a subfolder of it.
93-
10. `maps`: List of the names of the files of the campaigns mission maps
91+
8. `difficulty`: Difficulty of the campaign. Should be one of the values easy, medium or hard.
92+
9. `mapFolder` and `luaFolder`: Path to the folder containing the campaign maps and associated Lua files. Usually your campaign folder or a subfolder of it.
93+
10. `maps`: List of the names of the files of the campaigns' mission maps
9494
11. `selectionMap`: Optional parameter. See [map selection screen](#selection-map) for detailed explanations.
9595

9696
Hints:
97-
- To work on case sensitive os (like linux) the file name of the lua file must have the same case as the map file name. This applies to the map names in the campaign.lua file too.
98-
For example: `MISS01.WLD, MISS01.lua` is correct and `MISS01.WLD, miss01.lua` will not work on linux
99-
- The lua file of a map must have the same name as the map itself but with the extension `.lua` to be found.
100-
- The lua and the map file don't need to be in the same folder because the path can be specified separately.
101-
- If `mapFolder` is not specified or empty it defaults to the folder containing the campaign lua file.
102-
- If `luaFolder` is not specified it defaults to the `mapFolder`.
103-
- Both paths can start with placeholders like `<RTTR_GAME>`, otherwise they need to be only the name of a folder relative to the folder containing the campaign lua file. I.e. multiple levels are not supported.
97+
98+
- To work on case-sensitive OS (like Linux) the file name of the Lua file must have the same case as the map file name. This applies to the map names in the campaign.lua file too.
99+
For example: `MISS01.WLD, MISS01.lua` is correct and `MISS01.WLD, miss01.lua` will not work on Linux
100+
- The Lua file of a map must have the same name as the map itself but with the extension `.lua` to be found.
101+
- The Lua and the map file don't need to be in the same folder because the path can be specified separately.
102+
- If `luaFolder` is not specified it defaults to the `mapFolder`, which defaults to an empty value.
103+
- Both paths can start with placeholders like `<RTTR_GAME>`,
104+
otherwise they must be (only) the name of a folder relative to the folder containing the campaign Lua file.
105+
I.e. multiple levels are not supported.
106+
In particular an empty value refers to the folder containing the campaign Lua file itself.
104107

105108
### Optional map selection screen {#selection-map}
106109

107-
This parameter is optional and can be obmitted in the lua campaign file. If this parameter is specified the selection screen for the missions of a campaign is replaced by a selection map. Like the one used in the original settler 2 world campaign.
110+
This parameter is optional and can be omitted in the Lua campaign file. If this parameter is specified the selection screen for the missions of a campaign is replaced by a selection map. Like the one used in the original settlers 2 world campaign.
108111

109112
We have the following parameters:
113+
110114
1. `background` background image for the selection map
111115
2. `map` the map image itself
112116
3. `missionMapMask` this image is a mask that describes the mission areas of the `map` image. It must be the same size as the `map` image where the color of each pixel determines the mission it belongs to. Each mission must have a unique color (specified in the `missionSelectionInfos`). Any other color is treated as neutral area and ignored.
113117
4. `marker` the marker image shown when a mission is selected
114118
5. `conquered` the image shown when a mission is already finished
115119
6. `backgroundOffset` offset of the `map` image and `missionMapMask` image relative to the `background` image. Can be (0,0) if no offset exists.
116120
7. `disabledColor` color for drawing missions not playable yet. Usually this should be a partly transparent color
117-
8. `missionSelectionInfos` contains an entry for each mission and must be the same order as specified in `maps` lua parameter. Each entry consists of three elements. The first is the `maskAreaColor` and the two following are the `ankerPos` x and y position. The `ankerPos` is the position the `conquered` image and the `cursor` image, if mission is selected, are displayed for this mission. The offset is always counted from the origin of the `map` image. The `maskAreaColor` is the color for the mission used in the `missionMapMask`.
121+
8. `missionSelectionInfos` contains an entry for each mission and must be the same order as specified in `maps` Lua parameter. Each entry consists of three elements. The first is the `maskAreaColor` and the two following are the `ankerPos` x and y position. The `ankerPos` is the position the `conquered` image and the `cursor` image, if mission is selected, are displayed for this mission. The offset is always counted from the origin of the `map` image. The `maskAreaColor` is the color for the mission used in the `missionMapMask`.
118122

119-
Hints:
120-
- All the images are described by the path to the image file and an index parameter. Usually the index parameter is zero. For special image formats containing multiple images in an archive this is the index of the image to use.
123+
Hint:
124+
All the images are described by the path to the image file and an index parameter. Usually the index parameter is zero.
125+
For special image formats containing multiple images in an archive this is the index of the image to use.
121126

122127
## Final view of the example garden campaign folder
123-
```
128+
129+
```sh
124130
RTTR/campaigns/garden
125131
RTTR/campaigns/garden/campaign.lua
126132
RTTR/campaigns/garden/garden.bmp
@@ -133,5 +139,4 @@ RTTR/campaigns/garden/mapscreen/map.bmp
133139
RTTR/campaigns/garden/mapscreen/map_mask.bmp
134140
RTTR/campaigns/garden/mapscreen/marker.bmp
135141
RTTR/campaigns/garden/mapscreen/conquered.bmp
136-
137-
```
142+
```

external/s25update

extras/videoDrivers/SDL2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (C) 2005 - 2021 Settlers Freaks <sf-team at siedler25.org>
1+
# Copyright (C) 2005 - 2024 Settlers Freaks <sf-team at siedler25.org>
22
#
33
# SPDX-License-Identifier: GPL-2.0-or-later
44

55
set(SDL2_BUILDING_LIBRARY ON)
6-
find_package(SDL2 2.0.2)
6+
find_package(SDL2 2.0.5)
77

88
if(SDL2_FOUND)
99
add_library(videoSDL2 SHARED ${RTTR_DRIVER_INTERFACE} VideoSDL2.cpp VideoSDL2.h icon.h icon.cpp)

extras/videoDrivers/SDL2/VideoSDL2.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
133133

134134
const auto requestedSize = fullscreen ? FindClosestVideoMode(size) : size;
135135
unsigned commonFlags = SDL_WINDOW_OPENGL;
136-
137-
#if SDL_VERSION_ATLEAST(2, 0, 1)
138-
commonFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
139-
#endif
136+
// TODO: Fix GUI scaling with High DPI support enabled.
137+
// See https://github.com/Return-To-The-Roots/s25client/issues/1621
138+
// commonFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
140139

141140
window = SDL_CreateWindow(title.c_str(), wndPos, wndPos, requestedSize.width, requestedSize.height,
142141
commonFlags | (fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE));
@@ -193,9 +192,7 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
193192
isFullscreen_ = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) != 0;
194193
if(!isFullscreen_)
195194
{
196-
#if SDL_VERSION_ATLEAST(2, 0, 5)
197195
SDL_SetWindowResizable(window, SDL_TRUE);
198-
#endif
199196
MoveWindowToCenter();
200197
}
201198
}
@@ -391,10 +388,8 @@ bool VideoSDL2::MessageLoop()
391388
case SDL_MOUSEWHEEL:
392389
{
393390
int y = ev.wheel.y;
394-
#if SDL_VERSION_ATLEAST(2, 0, 4)
395391
if(ev.wheel.direction == SDL_MOUSEWHEEL_FLIPPED)
396392
y = -y;
397-
#endif
398393
if(y > 0)
399394
CallBack->Msg_WheelUp(mouse_xy);
400395
else if(y < 0)
@@ -471,18 +466,11 @@ void* VideoSDL2::GetMapPointer() const
471466
void VideoSDL2::MoveWindowToCenter()
472467
{
473468
SDL_Rect usableBounds;
474-
#if SDL_VERSION_ATLEAST(2, 0, 5)
475469
CHECK_SDL(SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(window), &usableBounds));
476470
int top, left, bottom, right;
477471
CHECK_SDL(SDL_GetWindowBordersSize(window, &top, &left, &bottom, &right));
478472
usableBounds.w -= left + right;
479473
usableBounds.h -= top + bottom;
480-
#else
481-
CHECK_SDL(SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &usableBounds));
482-
// rough estimates
483-
usableBounds.w -= 10;
484-
usableBounds.h -= 30;
485-
#endif
486474
if(usableBounds.w < GetWindowSize().width || usableBounds.h < GetWindowSize().height)
487475
{
488476
SDL_SetWindowSize(window, usableBounds.w, usableBounds.h);

libs/s25main/Ware.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,27 +338,25 @@ unsigned Ware::CheckNewGoalForLostWare(const noBaseBuilding& newgoal) const
338338
Ware::RouteParams Ware::CalcPathToGoal(const noBaseBuilding& newgoal) const
339339
{
340340
RTTR_Assert(location);
341-
unsigned length = 0xFFFFFFFF;
341+
unsigned length;
342342
RoadPathDirection possibledir = world->FindPathForWareOnRoads(*location, newgoal, &length);
343343
if(possibledir != RoadPathDirection::None) // there is a valid path to the goal? -> ordered!
344344
{
345345
// in case the ware is right in front of the goal building the ware has to be moved away 1 flag and then back
346346
// because non-warehouses cannot just carry in new wares they need a helper to do this
347347
if(possibledir == RoadPathDirection::NorthWest && newgoal.GetFlagPos() == location->GetPos())
348348
{
349+
// Not executed for road from flag to the warehouse as that is handled directly by the warehouse
350+
RTTR_Assert(!BuildingProperties::IsWareHouse(newgoal.GetBuildingType()));
349351
for(const auto dir : helpers::EnumRange<Direction>{})
350352
{
353+
// Bounce of in this direction
351354
if(dir != Direction::NorthWest && location->GetRoute(dir))
352-
{
353-
possibledir = toRoadPathDirection(dir);
354-
break;
355-
}
355+
return {1, toRoadPathDirection(dir)};
356356
}
357-
if(possibledir == RoadPathDirection::NorthWest) // got no other route from the flag -> impossible
358-
return {0xFFFFFFFF, RoadPathDirection::None};
357+
// got no other route from the flag -> impossible
358+
return {0xFFFFFFFF, RoadPathDirection::None};
359359
}
360-
// at this point there either is a road to the goal
361-
// or we are at the flag of the goal and have a road to a different flag to bounce off of to get to the goal
362360
return {length, possibledir};
363361
}
364362
return {0xFFFFFFFF, RoadPathDirection::None};

0 commit comments

Comments
 (0)