12345678910111213141516171819202122232425262728293031 |
- #ifndef PACKETS_H
- #define PACKETS_H
- #include "math/Vector.h"
- #include "network/Packet.h"
- namespace Packets {
- // packets from the server to clients
- enum ServerPacket { S_CHAT, S_WORLD_SEGMENT, S_ENTITY_UPDATE };
- // packets from clients to the server
- enum ClientPacket { C_CHAT, C_PLAYER_UPDATE };
- template<int N>
- void writeVector(OutPacket& out, const Vector<N>& v) {
- for(int i = 0; i < N; i++) {
- out.writeFloat(v[i]);
- }
- }
- template<int N>
- bool readVector(InPacket& in, Vector<N>& v) {
- for(int i = 0; i < N; i++) {
- if(in.readFloat(v[i])) {
- return true;
- }
- }
- return false;
- }
- }
- #endif
|