SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
CommonNetStructures.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 
10 #include <glm/vec3.hpp>
11 #include <glm/mat4x3.hpp>
12 #include "BitStream.h"
14 
15 class QString;
16 
18 {
19 public:
20  TransformStruct(const glm::vec3 &a,const glm::vec3 &b,const glm::vec3 &c,bool set1,bool set2,bool set3) :
21  v1(a),v2(b),v3(c),v1_set(set1),v2_set(set2),v3_set(set3)
22  {
23  }
25  glm::vec3 v1;
26  glm::vec3 v2;
27  glm::vec3 v3;
29  template<class Archive>
30  void serialize(Archive &ar)
31  {
32  ar(v1,v2,v3);
33  ar(v1_set,v2_set,v3_set);
34  }
35 };
36 
41 {
42 public:
43  virtual void packColor(uint32_t c,BitStream &into) const=0;
44  virtual void unpackColor(BitStream &from,uint32_t &tgt) const =0;
45  virtual void packPartname(const QString &c,BitStream &into) const =0;
46  virtual void unpackPartname(BitStream &from,QString &tgt) const =0;
47 };
53 {
54 public:
55  virtual void addString(const QString &) = 0;
57  virtual int getIndex(const QString &) const =0;
58 };
59 extern void storeBitsConditional(BitStream &bs, uint8_t numbits, int bits);
60 extern int getBitsConditional(BitStream &bs, uint32_t numbits);
61 extern void storePackedBitsConditional(BitStream &bs, uint8_t numbits, int bits);
62 extern void storeFloatConditional(BitStream &bs,float val);
63 extern void storeFloatPacked(BitStream &bs,float val);
64 extern int getPackedBitsConditional(BitStream &bs, uint8_t numbits);
65 extern void storeStringConditional(BitStream &bs, const QString &str);
66 extern void storeVector(BitStream &bs, glm::vec3 &vec);
67 extern void storeVectorConditional(BitStream &bs, glm::vec3 &vec);
68 extern void storeTransformMatrix(BitStream &tgt,const glm::mat4x3 &src);
69 extern void storeTransformMatrix(BitStream &tgt,const TransformStruct &src);
70 extern void getTransformMatrix(BitStream &bs,glm::mat4x3 &src);
71 extern void storeCached_Color(BitStream &bs, uint32_t col, ColorHash &color_hash, uint32_t bitcount);
72 extern void storeCached_String(BitStream &bs, const QString &str,const StringHash &string_hash, uint32_t bitc);
73 extern uint32_t getCached_Color(BitStream &bs,ColorHash &color_hash, uint32_t bitcount);
74 extern QString getCached_String(BitStream &bs, const StringHash &string_hash, uint32_t bitcount);
The ColorAndPartPacker class is responsible for packing/unpacking colors and part names from BitStrea...
Definition: CommonNetStructures.h:40
Definition: CoXHash.h:198
glm::vec3 v2
Definition: CommonNetStructures.h:26
bool v1_set
Definition: CommonNetStructures.h:28
int getPackedBitsConditional(BitStream &bs, uint8_t numbits)
Definition: CommonNetStructures.cpp:71
Definition: CoXHash.h:160
Definition: BitStream.h:34
void storeVectorConditional(BitStream &bs, glm::vec3 &vec)
Definition: CommonNetStructures.cpp:51
void storeFloatPacked(BitStream &bs, float val)
Definition: CommonNetStructures.cpp:65
void serialize(Archive &ar)
Definition: CommonNetStructures.h:30
bool v2_set
Definition: CommonNetStructures.h:28
void storeCached_String(BitStream &bs, const QString &str, const StringHash &string_hash, uint32_t bitc)
QString getCached_String(BitStream &bs, const StringHash &string_hash, uint32_t bitcount)
void storeTransformMatrix(BitStream &tgt, const glm::mat4x3 &src)
Definition: CommonNetStructures.cpp:87
void storeVector(BitStream &bs, glm::vec3 &vec)
Definition: CommonNetStructures.cpp:44
int getBitsConditional(BitStream &bs, uint32_t numbits)
Definition: CommonNetStructures.cpp:28
glm::vec3 v1
Definition: CommonNetStructures.h:25
uint32_t getCached_Color(BitStream &bs, ColorHash &color_hash, uint32_t bitcount)
Definition: CommonNetStructures.h:17
TransformStruct()
Definition: CommonNetStructures.h:24
void getTransformMatrix(BitStream &bs, glm::mat4x3 &src)
Definition: CommonNetStructures.cpp:116
void storeFloatConditional(BitStream &bs, float val)
Definition: CommonNetStructures.cpp:58
TransformStruct(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, bool set1, bool set2, bool set3)
Definition: CommonNetStructures.h:20
glm::vec3 v3
Definition: CommonNetStructures.h:27
bool v3_set
Definition: CommonNetStructures.h:28
void storeBitsConditional(BitStream &bs, uint8_t numbits, int bits)
Definition: CommonNetStructures.cpp:21
void storePackedBitsConditional(BitStream &bs, uint8_t numbits, int bits)
Definition: CommonNetStructures.cpp:37
void storeCached_Color(BitStream &bs, uint32_t col, ColorHash &color_hash, uint32_t bitcount)
The IndexedStringPacker class is responsible for storing a mapping from string to index So when sendi...
Definition: CommonNetStructures.h:52
void storeStringConditional(BitStream &bs, const QString &str)
Definition: CommonNetStructures.cpp:80