Skip to content

Commit d4e4462

Browse files
committed
update
1 parent 296d9a1 commit d4e4462

File tree

10 files changed

+56
-80
lines changed

10 files changed

+56
-80
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
cmake --version
2424
git --version
2525
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727
with:
2828
submodules: recursive
2929

@@ -32,7 +32,7 @@ jobs:
3232
run: |
3333
mkdir build
3434
cd build
35-
cmake -A${{ matrix.build-arch }} ${{ matrix.build-tool }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} ..
35+
cmake -A${{ matrix.build-arch }} ${{ matrix.build-tool }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} -Dcage_use_steam_sockets=OFF ..
3636
3737
- name: Build
3838
shell: bash
@@ -55,30 +55,25 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
os-version: [22]
59-
build-config: [debug, release, relwithdebinfo]
58+
os-version: [24]
59+
build-config: [debug, release]
6060
compiler:
61-
- {
62-
cc: gcc-12,
63-
cxx: g++-12,
64-
install: gcc-12 g++-12
65-
}
6661
- {
6762
cc: gcc-13,
6863
cxx: g++-13,
6964
install: gcc-13 g++-13
7065
}
7166
- {
72-
cc: clang-15,
73-
cxx: clang++-15,
74-
install: clang-15
67+
cc: clang-18,
68+
cxx: clang++-18,
69+
install: clang-18
7570
}
7671

7772
steps:
7873
- name: Install packages
7974
run: |
8075
sudo apt-get update
81-
sudo apt-get install -y xorg-dev nasm ${{ matrix.compiler.install }}
76+
sudo apt-get install -y xorg-dev libwayland-dev libxkbcommon-dev libpulse-dev libasound2-dev nasm libssl-dev ${{ matrix.compiler.install }}
8277
8378
- name: Versions
8479
run: |
@@ -87,20 +82,20 @@ jobs:
8782
${{ matrix.compiler.cc }} --version
8883
${{ matrix.compiler.cxx }} --version
8984
90-
- uses: actions/checkout@v3
85+
- uses: actions/checkout@v4
9186
with:
9287
submodules: recursive
9388

9489
- name: Configure
9590
run: |
9691
mkdir build
9792
cd build
98-
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} ..
93+
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} -Dcage_use_steam_sockets=0 ..
9994
10095
- name: Build
10196
run: |
10297
cd build
103-
cmake --build . --config ${{ matrix.build-config }} -- -j3
98+
cmake --build . -- -j$(( `nproc` + 1 ))
10499
105100
- name: Assets
106101
run: |

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ target_link_libraries(space-ants cage-simple)
1414
cage_ide_category(space-ants space-ants)
1515
cage_ide_sort_files(space-ants)
1616
cage_ide_working_dir_in_place(space-ants)
17+
cage_ide_startup_project(space-ants)

externals/cage

Submodule cage updated 319 files

sources/camera.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "common.h"
2-
31
#include <cage-core/hashString.h>
42
#include <cage-core/variableSmoothingBuffer.h>
53
#include <cage-engine/sceneScreenSpaceEffects.h>
64
#include <cage-engine/window.h>
75
#include <cage-simple/fpsCamera.h>
86

7+
#include "common.h"
8+
99
namespace
1010
{
1111
class AutoCamera
@@ -15,7 +15,7 @@ namespace
1515

1616
void updatePositions()
1717
{
18-
if (engineEntities()->has(shipName))
18+
if (engineEntities()->exists(shipName))
1919
{
2020
Entity *ship = engineEntities()->get(shipName);
2121
TransformComponent &t = ship->value<TransformComponent>();
@@ -28,7 +28,7 @@ namespace
2828
{
2929
uint32 cnt = engineEntities()->component<ShipComponent>()->count();
3030
uint32 i = randomRange(0u, cnt);
31-
shipName = engineEntities()->component<ShipComponent>()->entities()[i]->name();
31+
shipName = engineEntities()->component<ShipComponent>()->entities()[i]->id();
3232
}
3333
}
3434

sources/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#ifndef ants_common_h_sdg456ds4hg6
22
#define ants_common_h_sdg456ds4hg6
33

4+
//#include <atomic>
5+
46
#include <cage-core/entities.h>
57
#include <cage-core/entitiesVisitor.h>
68
#include <cage-core/math.h>
79
#include <cage-core/profiling.h>
810
#include <cage-engine/scene.h>
911
#include <cage-simple/engine.h>
1012

11-
#include <atomic>
12-
1313
using namespace cage;
1414

1515
struct PhysicsComponent

sources/gui.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "common.h"
1+
#include <initializer_list>
22

33
#include <cage-core/string.h>
44
#include <cage-engine/guiBuilder.h>
55
#include <cage-engine/guiManager.h>
66

7-
#include <initializer_list>
7+
#include "common.h"
88

99
namespace
1010
{
@@ -32,7 +32,7 @@ namespace
3232

3333
void guiEvent(input::GuiValue in)
3434
{
35-
const uint32 index = in.entity->name() - 20;
35+
const uint32 index = in.entity->id() - 20;
3636
if (index < array_size(propertyValues))
3737
{
3838
GuiInputComponent &input = in.entity->value<GuiInputComponent>();

sources/main.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#include <cage-core/assetManager.h>
2-
#include <cage-core/config.h>
1+
#include <cage-core/assetsManager.h>
32
#include <cage-core/hashString.h>
4-
#include <cage-core/ini.h>
53
#include <cage-core/logger.h>
6-
#include <cage-core/math.h>
7-
84
#include <cage-engine/highPerformanceGpuHint.h>
95
#include <cage-engine/window.h>
106
#include <cage-simple/engine.h>
@@ -17,27 +13,22 @@ int main(int argc, const char *args[])
1713
{
1814
try
1915
{
20-
Holder<Logger> log1 = newLogger();
21-
log1->format.bind<logFormatConsole>();
22-
log1->output.bind<logOutputStdOut>();
23-
24-
configSetBool("cage/config/autoSave", true);
16+
initializeConsoleLogger();
2517
engineInitialize(EngineCreateConfig());
26-
controlThread().updatePeriod(1000000 / 30);
27-
engineAssets()->add(HashString("ants/ants.pack"));
18+
controlThread().updatePeriod(1'000'000 / 30);
19+
engineAssets()->load(HashString("ants/ants.pack"));
2820

2921
const auto closeListener = engineWindow()->events.listen(inputFilter([](input::WindowClose) { engineStop(); }));
3022
engineWindow()->title("space-ants");
3123

3224
{
3325
Holder<FullscreenSwitcher> fullscreen = newFullscreenSwitcher({});
3426
Holder<StatisticsGui> engineStatistics = newStatisticsGui();
35-
engineStatistics->statisticsScope = StatisticsGuiScopeEnum::None;
3627

3728
engineRun();
3829
}
3930

40-
engineAssets()->remove(HashString("ants/ants.pack"));
31+
engineAssets()->unload(HashString("ants/ants.pack"));
4132
engineFinalize();
4233
return 0;
4334
}

sources/planets.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include "common.h"
1+
#include <vector>
22

33
#include <cage-core/color.h>
44
#include <cage-core/hashString.h>
55

6-
#include <vector>
6+
#include "common.h"
77

88
namespace
99
{
10-
constexpr const uint32 modelNames[] = {
10+
constexpr uint32 modelNames[] = {
1111
HashString("ants/planets/farcodev/0.object"),
1212
HashString("ants/planets/farcodev/1.object"),
1313
HashString("ants/planets/farcodev/2.object"),
@@ -48,12 +48,9 @@ namespace
4848
RenderComponent &r = e->value<RenderComponent>();
4949
r.object = modelNames[randomRange(0u, (uint32)(sizeof(modelNames) / sizeof(modelNames[0])))];
5050
r.color = playerColors[owner.owner];
51-
PhysicsComponent &physics = e->value<PhysicsComponent>();
52-
physics.rotation = interpolate(Quat(), randomDirectionQuat(), 0.0003);
53-
LifeComponent &life = e->value<LifeComponent>();
54-
life.life = randomRange(1000000, 2000000);
55-
PlanetComponent &planet = e->value<PlanetComponent>();
56-
planet.batch = randomRange(3 * batchScale, 5 * batchScale);
51+
e->value<PhysicsComponent>().rotation = interpolate(Quat(), randomDirectionQuat(), 0.0003);
52+
e->value<LifeComponent>().life = randomRange(1000000, 2000000);
53+
e->value<PlanetComponent>().batch = randomRange(3 * batchScale, 5 * batchScale);
5754
}
5855
},
5956
-50);
@@ -66,18 +63,13 @@ namespace
6663
t.scale = 0.3;
6764
t.position = planetTransform.position + randomDirection3() * (t.scale + planetTransform.scale + 1e-5);
6865
t.orientation = randomDirectionQuat();
69-
OwnerComponent &planetOwner = (planet)->value<OwnerComponent>();
70-
OwnerComponent &owner = e->value<OwnerComponent>();
71-
owner.owner = planetOwner.owner;
72-
RenderComponent &planetRender = planet->value<RenderComponent>();
66+
e->value<OwnerComponent>().owner = planet->value<OwnerComponent>().owner;
7367
RenderComponent &r = e->value<RenderComponent>();
74-
r.color = planetRender.color;
68+
r.color = planet->value<RenderComponent>().color;
7569
r.object = HashString("ants/ships/1/1.object");
76-
PhysicsComponent &physics = e->value<PhysicsComponent>();
77-
LifeComponent &life = e->value<LifeComponent>();
78-
life.life = randomRange(200, 300);
79-
ShipComponent &ship = e->value<ShipComponent>();
80-
ship.longtermTarget = target;
70+
e->value<PhysicsComponent>();
71+
e->value<LifeComponent>().life = randomRange(200, 300);
72+
e->value<ShipComponent>().longtermTarget = target;
8173
}
8274

8375
uint32 planetIndex = 0;
@@ -96,8 +88,7 @@ namespace
9688
continue;
9789
if (shipsCount + p.batch > shipsLimit)
9890
continue;
99-
OwnerComponent &owner = e->value<OwnerComponent>();
100-
uint32 target = pickTargetPlanet(owner.owner);
91+
uint32 target = pickTargetPlanet(e->value<OwnerComponent>().owner);
10192
for (uint32 s = 0; s < p.batch; s++)
10293
createShip(e, target);
10394
p.batch = randomRange(3 * batchScale, 5 * batchScale);

sources/ships.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#include "common.h"
1+
#include <algorithm>
2+
#include <atomic>
3+
#include <random>
4+
#include <vector>
25

36
#include <cage-core/concurrent.h>
47
#include <cage-core/geometry.h>
@@ -9,10 +12,7 @@
912
#include <cage-core/timer.h>
1013
#include <cage-core/variableSmoothingBuffer.h>
1114

12-
#include <algorithm>
13-
#include <atomic>
14-
#include <random>
15-
#include <vector>
15+
#include "common.h"
1616

1717
uint32 pickTargetPlanet(uint32 shipOwner)
1818
{
@@ -22,7 +22,7 @@ uint32 pickTargetPlanet(uint32 shipOwner)
2222
for (Entity *e : planets)
2323
{
2424
if (e->value<OwnerComponent>().owner != shipOwner)
25-
return e->name();
25+
return e->id();
2626
}
2727
return 0;
2828
}
@@ -73,7 +73,7 @@ namespace
7373
// find all nearby objects
7474
spatialQuery->intersection(Sphere(t.position, t.scale + shipDetectRadius));
7575
shipsInteracted += numeric_cast<uint32>(spatialQuery->result().size());
76-
const uint32 myName = e->name();
76+
const uint32 myName = e->id();
7777
Vec3 avgPos;
7878
Vec3 avgDir;
7979
uint32 avgCnt = 0;
@@ -129,20 +129,20 @@ namespace
129129

130130
// choose a target to follow
131131
uint32 targetName = 0;
132-
if (engineEntities()->has(s.currentTarget))
132+
if (engineEntities()->exists(s.currentTarget))
133133
targetName = s.currentTarget;
134134
else if (closestTargetName)
135135
targetName = s.currentTarget = closestTargetName;
136136
else
137137
{
138138
// use long-term goal
139-
if (!engineEntities()->has(s.longtermTarget))
139+
if (!engineEntities()->exists(s.longtermTarget))
140140
s.longtermTarget = pickTargetPlanet(owner.owner);
141141
targetName = s.longtermTarget;
142142
}
143143

144144
// accelerate towards target
145-
if (engineEntities()->has(targetName))
145+
if (engineEntities()->exists(targetName))
146146
{
147147
Entity *target = engineEntities()->get(targetName);
148148
const TransformComponent &targetTransform = target->value<TransformComponent>();
@@ -153,7 +153,7 @@ namespace
153153
}
154154

155155
// fire at closest enemy
156-
if (engineEntities()->has(closestTargetName))
156+
if (engineEntities()->exists(closestTargetName))
157157
{
158158
Entity *target = engineEntities()->get(closestTargetName);
159159
const TransformComponent &tt = target->value<TransformComponent>();
@@ -202,8 +202,8 @@ namespace
202202
entitiesVisitor(
203203
[&](Entity *e, const PhysicsComponent &, const TransformComponent &t)
204204
{
205-
if (e->name())
206-
spatialSearchData->update(e->name(), Sphere(t.position, t.scale));
205+
if (e->id())
206+
spatialSearchData->update(e->id(), Sphere(t.position, t.scale));
207207
},
208208
engineEntities(), false);
209209
spatialSearchData->rebuild();

sources/timeout.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "common.h"
2-
31
#include <cage-core/color.h>
42
#include <cage-core/hashString.h>
53

4+
#include "common.h"
5+
66
namespace
77
{
88
Vec3 colorVariation(const Vec3 &c)
@@ -36,10 +36,8 @@ namespace
3636
TextureAnimationComponent &at = e->value<TextureAnimationComponent>();
3737
at.startTime = engineControlTime();
3838
at.speed = randomRange(0.7, 1.5);
39-
PhysicsComponent &p = e->value<PhysicsComponent>();
40-
p.velocity = randomDirection3() * t.scale * 0.07 + sp.velocity;
41-
TimeoutComponent &ttl = e->value<TimeoutComponent>();
42-
ttl.ttl = numeric_cast<sint32>(Real(30) / at.speed);
39+
e->value<PhysicsComponent>().velocity = randomDirection3() * t.scale * 0.07 + sp.velocity;
40+
e->value<TimeoutComponent>().ttl = numeric_cast<sint32>(Real(30) / at.speed);
4341
}
4442
}
4543

0 commit comments

Comments
 (0)