Skip to content

Commit 6113c66

Browse files
committed
ECS: Update some types with the rfc
PATCH
1 parent ae299fa commit 6113c66

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/Client/Systems/Network/ClientNetwork.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ namespace Systems {
9999
if (registry.getClock().elapsedMillisecondsSince(clockId) < delay) {
100100
return;
101101
}
102+
registry.getClock().restart(clockId);
102103
auto ids = registry.getEntitiesByComponents({typeid(Types::Position), typeid(Types::Player)});
103104
auto arrPosition = registry.getComponents<Types::Position>();
104105

@@ -112,7 +113,6 @@ namespace Systems {
112113
auto &posCached = positionPlayerCached.second;
113114
const auto &pos = arrPosition[positionPlayerCached.first];
114115
if (pos.x != posCached.x || pos.y != posCached.y) {
115-
registry.getClock().restart(clockId);
116116
struct position_relative_s msg = {
117117
.x = static_cast<char>(static_cast<int>(pos.x - posCached.x)),
118118
.y = static_cast<char>(static_cast<int>(pos.y - posCached.y)),

src/ECS/MessageTypes.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ enum enemy_type_e {
1515
CLASSIC_ENEMY = 0,
1616
};
1717

18-
enum missileTypes_e { CLASSIC };
18+
enum missileTypes_e {
19+
CLASSIC = 0,
20+
};
1921

2022
PACK(struct health_s {
2123
int hp;
2224
});
2325

2426
PACK(struct enemy_id_s {
25-
unsigned int id;
27+
n_id_t id;
2628
});
2729

2830
PACK(struct position_relative_s {
@@ -43,7 +45,7 @@ PACK(struct enemy_infos_s {
4345
});
4446

4547
PACK(struct player_infos_s {
46-
unsigned int id;
48+
n_id_t id;
4749
struct position_absolute_s pos;
4850
});
4951

src/Nitwork/Nitwork.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222

2323
#define MAGICK_INIT '\x06'
2424
#define MAGICK_READY '\x17'
25-
#define MAGICK_START_WAVE '\a'
26-
#define MAGICK_POSITION_RELATIVE '\b'
27-
#define MAGICK_POSITION_ABSOLUTE '\f'
25+
#define MAGICK_START_WAVE '\x07'
26+
#define MAGICK_POSITION_RELATIVE '\x08'
27+
#define MAGICK_POSITION_ABSOLUTE '\x09'
2828
#define MAGICK_LIFE_UPDATE '\x0b'
2929
#define MAGICK_ENEMY_DEATH '\x0c'
3030
#define MAGICK_NEW_ENEMY '\x0e'
3131
#define MAGICK_NEW_BULLET '\x0c'
32+
#define MAGICK_POSITION_RELATIVE_BROADCAST '\x0f'
33+
#define MAGICK_POSITION_ABSOLUTE_BROADCAST '\xae'
34+
#define MAGICK_NEW_ALLIE '\x0a'
3235

33-
typedef char n_magick_t;
36+
typedef unsigned char n_magick_t;
3437
typedef int n_idsReceived_t;
3538
typedef unsigned char n_nbAction_t;
3639

@@ -198,8 +201,8 @@ PACK(struct packetNewAllie_s {
198201

199202
/* Message broadcast position relative */
200203
PACK(struct msgPositionRelativeBroadcast_s {
201-
char x;
202-
char y;
204+
n_magick_t magick;
205+
struct position_relative_s pos;
203206
n_id_t playerId;
204207
});
205208

src/Nitwork/NitworkServer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ namespace Nitwork {
152152
.magick2 = HEADER_CODE2},
153153
.action = {.magick = POSITION_RELATIVE_BROADCAST},
154154
.msg = {
155-
.x = pos.x,
156-
.y = pos.y,
157-
.playerId = getPlayerId(endpoint),
158-
}
155+
.magick = MAGICK_POSITION_RELATIVE_BROADCAST,
156+
.pos = {
157+
.x = pos.x,
158+
.y = pos.y},
159+
.playerId = getPlayerId(endpoint)}
159160
};
160161
Packet packet(
161162
msgPosBroadcast.action.magick,

0 commit comments

Comments
 (0)