| Quake II RTX doxygen
    1.0 dev
    |  | 
 
 
 
#include "g_local.h"
#include "g_ptrs.h"
Go to the source code of this file.
|  | 
| #define | _FA(type,  name,  size)   { type, _OFS(name), size } | 
|  | 
| #define | _F(type,  name)   _FA(type, name, 1) | 
|  | 
| #define | SZ(name,  size)   _FA(F_ZSTRING, name, size) | 
|  | 
| #define | BA(name,  size)   _FA(F_BYTE, name, size) | 
|  | 
| #define | B(name)   BA(name, 1) | 
|  | 
| #define | SA(name,  size)   _FA(F_SHORT, name, size) | 
|  | 
| #define | S(name)   SA(name, 1) | 
|  | 
| #define | IA(name,  size)   _FA(F_INT, name, size) | 
|  | 
| #define | I(name)   IA(name, 1) | 
|  | 
| #define | FA(name,  size)   _FA(F_FLOAT, name, size) | 
|  | 
| #define | F(name)   FA(name, 1) | 
|  | 
| #define | L(name)   _F(F_LSTRING, name) | 
|  | 
| #define | V(name)   _F(F_VECTOR, name) | 
|  | 
| #define | T(name)   _F(F_ITEM, name) | 
|  | 
| #define | E(name)   _F(F_EDICT, name) | 
|  | 
| #define | P(name,  type)   _FA(F_POINTER, name, type) | 
|  | 
| #define | _OFS   FOFS | 
|  | 
| #define | _OFS   LLOFS | 
|  | 
| #define | _OFS   CLOFS | 
|  | 
| #define | _OFS   GLOFS | 
|  | 
| #define | SAVE_MAGIC1   (('1'<<24)|('V'<<16)|('S'<<8)|'S') | 
|  | 
| #define | SAVE_MAGIC2   (('1'<<24)|('V'<<16)|('A'<<8)|'S') | 
|  | 
| #define | SAVE_VERSION   2 | 
|  | 
|  | 
| static void | write_data (void *buf, size_t len, FILE *f) | 
|  | 
| static void | write_short (FILE *f, short v) | 
|  | 
| static void | write_int (FILE *f, int v) | 
|  | 
| static void | write_float (FILE *f, float v) | 
|  | 
| static void | write_string (FILE *f, char *s) | 
|  | 
| static void | write_vector (FILE *f, vec_t *v) | 
|  | 
| static void | write_index (FILE *f, void *p, size_t size, void *start, int max_index) | 
|  | 
| static void | write_pointer (FILE *f, void *p, ptr_type_t type) | 
|  | 
| static void | write_field (FILE *f, const save_field_t *field, void *base) | 
|  | 
| static void | write_fields (FILE *f, const save_field_t *fields, void *base) | 
|  | 
| static void | read_data (void *buf, size_t len, FILE *f) | 
|  | 
| static int | read_short (FILE *f) | 
|  | 
| static int | read_int (FILE *f) | 
|  | 
| static float | read_float (FILE *f) | 
|  | 
| static char * | read_string (FILE *f) | 
|  | 
| static void | read_zstring (FILE *f, char *s, size_t size) | 
|  | 
| static void | read_vector (FILE *f, vec_t *v) | 
|  | 
| static void * | read_index (FILE *f, size_t size, void *start, int max_index) | 
|  | 
| static void * | read_pointer (FILE *f, ptr_type_t type) | 
|  | 
| static void | read_field (FILE *f, const save_field_t *field, void *base) | 
|  | 
| static void | read_fields (FILE *f, const save_field_t *fields, void *base) | 
|  | 
| void | WriteGame (const char *filename, qboolean autosave) | 
|  | 
| void | ReadGame (const char *filename) | 
|  | 
| void | WriteLevel (const char *filename) | 
|  | 
| void | ReadLevel (const char *filename) | 
|  | 
◆ _F
      
        
          | #define _F | ( |  | type, | 
        
          |  |  |  | name | 
        
          |  | ) |  | _FA(type, name, 1) | 
      
 
 
◆ _FA
      
        
          | #define _FA | ( |  | type, | 
        
          |  |  |  | name, | 
        
          |  |  |  | size | 
        
          |  | ) |  | { type, _OFS(name), size } | 
      
 
 
◆ _OFS [1/4]
◆ _OFS [2/4]
◆ _OFS [3/4]
◆ _OFS [4/4]
      
        
          | #define B | ( |  | name | ) | BA(name, 1) | 
      
 
 
◆ BA
      
        
          | #define BA | ( |  | name, | 
        
          |  |  |  | size | 
        
          |  | ) |  | _FA(F_BYTE, name, size) | 
      
 
 
      
        
          | #define F | ( |  | name | ) | FA(name, 1) | 
      
 
 
◆ FA
      
        
          | #define FA | ( |  | name, | 
        
          |  |  |  | size | 
        
          |  | ) |  | _FA(F_FLOAT, name, size) | 
      
 
 
      
        
          | #define I | ( |  | name | ) | IA(name, 1) | 
      
 
 
◆ IA
      
        
          | #define IA | ( |  | name, | 
        
          |  |  |  | size | 
        
          |  | ) |  | _FA(F_INT, name, size) | 
      
 
 
      
        
          | #define S | ( |  | name | ) | SA(name, 1) | 
      
 
 
◆ SA
      
        
          | #define SA | ( |  | name, | 
        
          |  |  |  | size | 
        
          |  | ) |  | _FA(F_SHORT, name, size) | 
      
 
 
◆ SAVE_MAGIC1
      
        
          | #define SAVE_MAGIC1   (('1'<<24)|('V'<<16)|('S'<<8)|'S') | 
      
 
 
◆ SAVE_MAGIC2
      
        
          | #define SAVE_MAGIC2   (('1'<<24)|('V'<<16)|('A'<<8)|'S') | 
      
 
 
◆ SAVE_VERSION
◆ SZ
◆ read_data()
  
  | 
        
          | static void read_data | ( | void * | buf, |  
          |  |  | size_t | len, |  
          |  |  | FILE * | f |  
          |  | ) |  |  |  | static | 
 
Definition at line 582 of file g_save.c.
  584     if (fread(buf, 1, len, f) != len) {
 
  585         gi.error(
"%s: couldn't read %"PRIz
" bytes", __func__, len);
 
 
Referenced by read_field(), read_float(), read_int(), read_short(), read_string(), and read_zstring().
 
 
◆ read_field()
Definition at line 701 of file g_save.c.
  703     void *p = (
byte *)base + field->
ofs;
 
  706     switch (field->
type) {
 
  711         for (i = 0; i < field->
size; i++) {
 
  716         for (i = 0; i < field->
size; i++) {
 
  721         for (i = 0; i < field->
size; i++) {
 
  751         gi.error(
"%s: unknown field type", __func__);
 
 
Referenced by read_fields().
 
 
◆ read_fields()
◆ read_float()
  
  | 
        
          | static float read_float | ( | FILE * | f | ) |  |  | static | 
 
 
◆ read_index()
  
  | 
        
          | static void* read_index | ( | FILE * | f, |  
          |  |  | size_t | size, |  
          |  |  | void * | start, |  
          |  |  | int | max_index |  
          |  | ) |  |  |  | static | 
 
Definition at line 661 of file g_save.c.
  671     if (index < 0 || index > max_index) {
 
  672         gi.error(
"%s: bad index", __func__);
 
  675     p = (
byte *)start + index * size;
 
 
Referenced by read_field().
 
 
◆ read_int()
  
  | 
        
          | static int read_int | ( | FILE * | f | ) |  |  | static | 
 
 
◆ read_pointer()
Definition at line 679 of file g_save.c.
  690         gi.error(
"%s: bad index", __func__);
 
  694     if (ptr->
type != type) {
 
  695         gi.error(
"%s: type mismatch", __func__);
 
 
Referenced by read_field().
 
 
◆ read_short()
  
  | 
        
          | static int read_short | ( | FILE * | f | ) |  |  | static | 
 
 
◆ read_string()
  
  | 
        
          | static char* read_string | ( | FILE * | f | ) |  |  | static | 
 
Definition at line 620 of file g_save.c.
  630     if (len < 0 || len > 65536) {
 
  631         gi.error(
"%s: bad length", __func__);
 
 
Referenced by read_field().
 
 
◆ read_vector()
  
  | 
        
          | static void read_vector | ( | FILE * | f, |  
          |  |  | vec_t * | v |  
          |  | ) |  |  |  | static | 
 
 
◆ read_zstring()
  
  | 
        
          | static void read_zstring | ( | FILE * | f, |  
          |  |  | char * | s, |  
          |  |  | size_t | size |  
          |  | ) |  |  |  | static | 
 
Definition at line 641 of file g_save.c.
  646     if (len < 0 || len >= size) {
 
  647         gi.error(
"%s: bad length", __func__);
 
 
Referenced by read_field().
 
 
◆ ReadGame()
      
        
          | void ReadGame | ( | const char * | filename | ) |  | 
      
 
Definition at line 810 of file g_save.c.
  817     f = fopen(filename, 
"rb");
 
  819         gi.error(
"Couldn't open %s", filename);
 
  824         gi.error(
"Not a save game");
 
  830         gi.error(
"Savegame from an older version");
 
  838         gi.error(
"Savegame has bad maxclients");
 
  842         gi.error(
"Savegame has bad maxentities");
 
 
Referenced by GetGameAPI().
 
 
◆ ReadLevel()
      
        
          | void ReadLevel | ( | const char * | filename | ) |  | 
      
 
Definition at line 912 of file g_save.c.
  923     f = fopen(filename, 
"rb");
 
  925         gi.error(
"Couldn't open %s", filename);
 
  934         gi.error(
"Not a save game");
 
  940         gi.error(
"Savegame from an older version");
 
  952             gi.error(
"%s: bad entity number", __func__);
 
  954         if (entnum >= 
globals.num_edicts)
 
  955             globals.num_edicts = entnum + 1;
 
  960         ent->s.number = entnum;
 
  963         memset(&ent->area, 0, 
sizeof(ent->area));
 
  973         ent->client->pers.connected = qfalse;
 
  977     for (i = 0 ; i < 
globals.num_edicts ; i++) {
 
  985             if (strcmp(ent->classname, 
"target_crosslevel_target") == 0)
 
  986                 ent->nextthink = 
level.
time + ent->delay;
 
  989             char *
msg = ent->message;
 
 
Referenced by GetGameAPI().
 
 
◆ write_data()
  
  | 
        
          | static void write_data | ( | void * | buf, |  
          |  |  | size_t | len, |  
          |  |  | FILE * | f |  
          |  | ) |  |  |  | static | 
 
 
◆ write_field()
Definition at line 519 of file g_save.c.
  521     void *p = (
byte *)base + field->
ofs;
 
  524     switch (field->
type) {
 
  529         for (i = 0; i < field->
size; i++) {
 
  534         for (i = 0; i < field->
size; i++) {
 
  539         for (i = 0; i < field->
size; i++) {
 
  569         gi.error(
"%s: unknown field type", __func__);
 
 
Referenced by write_fields().
 
 
◆ write_fields()
◆ write_float()
  
  | 
        
          | static void write_float | ( | FILE * | f, |  
          |  |  | float | v |  
          |  | ) |  |  |  | static | 
 
 
◆ write_index()
  
  | 
        
          | static void write_index | ( | FILE * | f, |  
          |  |  | void * | p, |  
          |  |  | size_t | size, |  
          |  |  | void * | start, |  
          |  |  | int | max_index |  
          |  | ) |  |  |  | static | 
 
Definition at line 479 of file g_save.c.
  488     if (p < start || (
byte *)p > (
byte *)start + max_index * size) {
 
  489         gi.error(
"%s: pointer out of range: %p", __func__, p);
 
  492     diff = (
byte *)p - (
byte *)start;
 
  494         gi.error(
"%s: misaligned pointer: %p", __func__, p);
 
 
Referenced by write_field().
 
 
◆ write_int()
  
  | 
        
          | static void write_int | ( | FILE * | f, |  
          |  |  | int | v |  
          |  | ) |  |  |  | static | 
 
 
◆ write_pointer()
Definition at line 499 of file g_save.c.
  510         if (ptr->
type == type && ptr->
ptr == p) {
 
  516     gi.error(
"%s: unknown pointer: %p", __func__, p);
 
 
Referenced by write_field().
 
 
◆ write_short()
  
  | 
        
          | static void write_short | ( | FILE * | f, |  
          |  |  | short | v |  
          |  | ) |  |  |  | static | 
 
 
◆ write_string()
  
  | 
        
          | static void write_string | ( | FILE * | f, |  
          |  |  | char * | s |  
          |  | ) |  |  |  | static | 
 
 
◆ write_vector()
  
  | 
        
          | static void write_vector | ( | FILE * | f, |  
          |  |  | vec_t * | v |  
          |  | ) |  |  |  | static | 
 
 
◆ WriteGame()
      
        
          | void WriteGame | ( | const char * | filename, | 
        
          |  |  | qboolean | autosave | 
        
          |  | ) |  |  | 
      
 
Definition at line 784 of file g_save.c.
  792     f = fopen(filename, 
"wb");
 
  794         gi.error(
"Couldn't open %s", filename);
 
 
Referenced by GetGameAPI().
 
 
◆ WriteLevel()
      
        
          | void WriteLevel | ( | const char * | filename | ) |  | 
      
 
Definition at line 866 of file g_save.c.
  872     f = fopen(filename, 
"wb");
 
  874         gi.error(
"Couldn't open %s", filename);
 
  883     for (i = 0; i < 
globals.num_edicts; i++) {
 
 
Referenced by GetGameAPI().
 
 
◆ clientfields
◆ entityfields
◆ gamefields
◆ levelfields
 
 
static void write_int(FILE *f, int v)
static void * read_index(FILE *f, size_t size, void *start, int max_index)
static void write_vector(FILE *f, vec_t *v)
static void write_data(void *buf, size_t len, FILE *f)
static void write_fields(FILE *f, const save_field_t *fields, void *base)
static void write_short(FILE *f, short v)
static int read_int(FILE *f)
static void write_field(FILE *f, const save_field_t *field, void *base)
const save_ptr_t save_ptrs[]
static const save_field_t clientfields[]
static void write_pointer(FILE *f, void *p, ptr_type_t type)
static void read_field(FILE *f, const save_field_t *field, void *base)
static char * read_string(FILE *f)
static void write_string(FILE *f, char *s)
#define CLOCK_MESSAGE_SIZE
static void read_zstring(FILE *f, char *s, size_t size)
static void write_float(FILE *f, float v)
size_t Q_strlcpy(char *dst, const char *src, size_t size)
static const save_field_t gamefields[]
static const save_field_t entityfields[]
static void read_vector(FILE *f, vec_t *v)
static q_noinline int diff(uint32_t A_u32, uint32_t B_u32)
void func_clock_use(edict_t *self, edict_t *other, edict_t *activator)
static float read_float(FILE *f)
static void write_index(FILE *f, void *p, size_t size, void *start, int max_index)
static void read_data(void *buf, size_t len, FILE *f)
void func_clock_think(edict_t *self)
static int read_short(FILE *f)
void SaveClientData(void)
static const save_field_t levelfields[]
static void * read_pointer(FILE *f, ptr_type_t type)
static void read_fields(FILE *f, const save_field_t *fields, void *base)