diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-08 20:47:56 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-08 20:47:56 +0000 |
| commit | 3544db49270f6d99c8b2126f294d38267e2899cb (patch) | |
| tree | 02a17b114cacf8ce634d65c6f53f3b6537ee06ce /src/game/gamecore.hpp | |
| parent | 1d094181ed06edd6f9d851f5d802bc9d03b6c352 (diff) | |
| download | zcatch-3544db49270f6d99c8b2126f294d38267e2899cb.tar.gz zcatch-3544db49270f6d99c8b2126f294d38267e2899cb.zip | |
fixed #490 (insert the player info in the sv_setinfo message into the snapshot instead)
Diffstat (limited to 'src/game/gamecore.hpp')
| -rw-r--r-- | src/game/gamecore.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/game/gamecore.hpp b/src/game/gamecore.hpp index 0e0c1c4a..5db5207b 100644 --- a/src/game/gamecore.hpp +++ b/src/game/gamecore.hpp @@ -53,6 +53,41 @@ inline float get_angle(vec2 dir) return a; } +inline void str_to_ints(int *ints, int num, const char *str) +{ + int index = 0; + while(num) + { + char buf[4] = {0,0,0,0}; + for(int c = 0; c < 4 && str[index]; c++, index++) + buf[c] = str[index]; + *ints = (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3]; + ints++; + num--; + } + + // null terminate + ints[-1] &= 0xffffff00; +} + +inline void ints_to_str(const int *ints, int num, char *str) +{ + while(num) + { + str[0] = ((*ints)>>24)&0xff; + str[1] = ((*ints)>>16)&0xff; + str[2] = ((*ints)>>8)&0xff; + str[3] = (*ints)&0xff; + str += 4; + ints++; + num--; + } + + // null terminate + str[-1] = 0; +} + + inline vec2 calc_pos(vec2 p, vec2 v, float curvature, float speed, float t) { |