Quake II RTX doxygen  1.0 dev
g_save.c File Reference
#include "g_local.h"
#include "g_ptrs.h"

Go to the source code of this file.

Classes

struct  save_field_t
 

Macros

#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
 

Functions

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 voidread_index (FILE *f, size_t size, void *start, int max_index)
 
static voidread_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)
 

Variables

static const save_field_t entityfields []
 
static const save_field_t levelfields []
 
static const save_field_t clientfields []
 
static const save_field_t gamefields []
 

Macro Definition Documentation

◆ _F

#define _F (   type,
  name 
)    _FA(type, name, 1)

Definition at line 37 of file g_save.c.

◆ _FA

#define _FA (   type,
  name,
  size 
)    { type, _OFS(name), size }

Definition at line 35 of file g_save.c.

◆ _OFS [1/4]

#define _OFS   FOFS

◆ _OFS [2/4]

#define _OFS   LLOFS

◆ _OFS [3/4]

#define _OFS   CLOFS

◆ _OFS [4/4]

#define _OFS   GLOFS

◆ B

#define B (   name)    BA(name, 1)

Definition at line 40 of file g_save.c.

◆ BA

#define BA (   name,
  size 
)    _FA(F_BYTE, name, size)

Definition at line 39 of file g_save.c.

◆ E

#define E (   name)    _F(F_EDICT, name)

Definition at line 50 of file g_save.c.

◆ F

#define F (   name)    FA(name, 1)

Definition at line 46 of file g_save.c.

◆ FA

#define FA (   name,
  size 
)    _FA(F_FLOAT, name, size)

Definition at line 45 of file g_save.c.

◆ I

#define I (   name)    IA(name, 1)

Definition at line 44 of file g_save.c.

◆ IA

#define IA (   name,
  size 
)    _FA(F_INT, name, size)

Definition at line 43 of file g_save.c.

◆ L

#define L (   name)    _F(F_LSTRING, name)

Definition at line 47 of file g_save.c.

◆ P

#define P (   name,
  type 
)    _FA(F_POINTER, name, type)

Definition at line 51 of file g_save.c.

◆ S

#define S (   name)    SA(name, 1)

Definition at line 42 of file g_save.c.

◆ SA

#define SA (   name,
  size 
)    _FA(F_SHORT, name, size)

Definition at line 41 of file g_save.c.

◆ SAVE_MAGIC1

#define SAVE_MAGIC1   (('1'<<24)|('V'<<16)|('S'<<8)|'S')

Definition at line 766 of file g_save.c.

◆ SAVE_MAGIC2

#define SAVE_MAGIC2   (('1'<<24)|('V'<<16)|('A'<<8)|'S')

Definition at line 767 of file g_save.c.

◆ SAVE_VERSION

#define SAVE_VERSION   2

Definition at line 768 of file g_save.c.

◆ SZ

#define SZ (   name,
  size 
)    _FA(F_ZSTRING, name, size)

Definition at line 38 of file g_save.c.

◆ T

#define T (   name)    _F(F_ITEM, name)

Definition at line 49 of file g_save.c.

◆ V

#define V (   name)    _F(F_VECTOR, name)

Definition at line 48 of file g_save.c.

Function Documentation

◆ read_data()

static void read_data ( void buf,
size_t  len,
FILE *  f 
)
static

Definition at line 582 of file g_save.c.

583 {
584  if (fread(buf, 1, len, f) != len) {
585  gi.error("%s: couldn't read %"PRIz" bytes", __func__, len);
586  }
587 }

Referenced by read_field(), read_float(), read_int(), read_short(), read_string(), and read_zstring().

◆ read_field()

static void read_field ( FILE *  f,
const save_field_t field,
void base 
)
static

Definition at line 701 of file g_save.c.

702 {
703  void *p = (byte *)base + field->ofs;
704  int i;
705 
706  switch (field->type) {
707  case F_BYTE:
708  read_data(p, field->size, f);
709  break;
710  case F_SHORT:
711  for (i = 0; i < field->size; i++) {
712  ((short *)p)[i] = read_short(f);
713  }
714  break;
715  case F_INT:
716  for (i = 0; i < field->size; i++) {
717  ((int *)p)[i] = read_int(f);
718  }
719  break;
720  case F_FLOAT:
721  for (i = 0; i < field->size; i++) {
722  ((float *)p)[i] = read_float(f);
723  }
724  break;
725  case F_VECTOR:
726  read_vector(f, (vec_t *)p);
727  break;
728 
729  case F_LSTRING:
730  *(char **)p = read_string(f);
731  break;
732  case F_ZSTRING:
733  read_zstring(f, (char *)p, field->size);
734  break;
735 
736  case F_EDICT:
737  *(edict_t **)p = read_index(f, sizeof(edict_t), g_edicts, game.maxentities - 1);
738  break;
739  case F_CLIENT:
740  *(gclient_t **)p = read_index(f, sizeof(gclient_t), game.clients, game.maxclients - 1);
741  break;
742  case F_ITEM:
743  *(gitem_t **)p = read_index(f, sizeof(gitem_t), itemlist, game.num_items - 1);
744  break;
745 
746  case F_POINTER:
747  *(void **)p = read_pointer(f, field->size);
748  break;
749 
750  default:
751  gi.error("%s: unknown field type", __func__);
752  }
753 }

Referenced by read_fields().

◆ read_fields()

static void read_fields ( FILE *  f,
const save_field_t fields,
void base 
)
static

Definition at line 755 of file g_save.c.

756 {
757  const save_field_t *field;
758 
759  for (field = fields; field->type; field++) {
760  read_field(f, field, base);
761  }
762 }

Referenced by ReadGame(), and ReadLevel().

◆ read_float()

static float read_float ( FILE *  f)
static

Definition at line 609 of file g_save.c.

610 {
611  float v;
612 
613  read_data(&v, sizeof(v), f);
614  v = LittleFloat(v);
615 
616  return v;
617 }

Referenced by read_field(), and read_vector().

◆ 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.

662 {
663  int index;
664  byte *p;
665 
666  index = read_int(f);
667  if (index == -1) {
668  return NULL;
669  }
670 
671  if (index < 0 || index > max_index) {
672  gi.error("%s: bad index", __func__);
673  }
674 
675  p = (byte *)start + index * size;
676  return p;
677 }

Referenced by read_field().

◆ read_int()

static int read_int ( FILE *  f)
static

Definition at line 599 of file g_save.c.

600 {
601  int v;
602 
603  read_data(&v, sizeof(v), f);
604  v = LittleLong(v);
605 
606  return v;
607 }

Referenced by read_field(), read_index(), read_pointer(), read_string(), read_zstring(), ReadGame(), and ReadLevel().

◆ read_pointer()

static void* read_pointer ( FILE *  f,
ptr_type_t  type 
)
static

Definition at line 679 of file g_save.c.

680 {
681  int index;
682  const save_ptr_t *ptr;
683 
684  index = read_int(f);
685  if (index == -1) {
686  return NULL;
687  }
688 
689  if (index < 0 || index >= num_save_ptrs) {
690  gi.error("%s: bad index", __func__);
691  }
692 
693  ptr = &save_ptrs[index];
694  if (ptr->type != type) {
695  gi.error("%s: type mismatch", __func__);
696  }
697 
698  return ptr->ptr;
699 }

Referenced by read_field().

◆ read_short()

static int read_short ( FILE *  f)
static

Definition at line 589 of file g_save.c.

590 {
591  short v;
592 
593  read_data(&v, sizeof(v), f);
594  v = LittleShort(v);
595 
596  return v;
597 }

Referenced by read_field().

◆ read_string()

static char* read_string ( FILE *  f)
static

Definition at line 620 of file g_save.c.

621 {
622  int len;
623  char *s;
624 
625  len = read_int(f);
626  if (len == -1) {
627  return NULL;
628  }
629 
630  if (len < 0 || len > 65536) {
631  gi.error("%s: bad length", __func__);
632  }
633 
634  s = gi.TagMalloc(len + 1, TAG_LEVEL);
635  read_data(s, len, f);
636  s[len] = 0;
637 
638  return s;
639 }

Referenced by read_field().

◆ read_vector()

static void read_vector ( FILE *  f,
vec_t *  v 
)
static

Definition at line 654 of file g_save.c.

655 {
656  v[0] = read_float(f);
657  v[1] = read_float(f);
658  v[2] = read_float(f);
659 }

Referenced by read_field().

◆ read_zstring()

static void read_zstring ( FILE *  f,
char *  s,
size_t  size 
)
static

Definition at line 641 of file g_save.c.

642 {
643  int len;
644 
645  len = read_int(f);
646  if (len < 0 || len >= size) {
647  gi.error("%s: bad length", __func__);
648  }
649 
650  read_data(s, len, f);
651  s[len] = 0;
652 }

Referenced by read_field().

◆ ReadGame()

void ReadGame ( const char *  filename)

Definition at line 810 of file g_save.c.

811 {
812  FILE *f;
813  int i;
814 
815  gi.FreeTags(TAG_GAME);
816 
817  f = fopen(filename, "rb");
818  if (!f)
819  gi.error("Couldn't open %s", filename);
820 
821  i = read_int(f);
822  if (i != SAVE_MAGIC1) {
823  fclose(f);
824  gi.error("Not a save game");
825  }
826 
827  i = read_int(f);
828  if (i != SAVE_VERSION) {
829  fclose(f);
830  gi.error("Savegame from an older version");
831  }
832 
834 
835  // should agree with server's version
836  if (game.maxclients != (int)maxclients->value) {
837  fclose(f);
838  gi.error("Savegame has bad maxclients");
839  }
840  if (game.maxentities <= game.maxclients || game.maxentities > MAX_EDICTS) {
841  fclose(f);
842  gi.error("Savegame has bad maxentities");
843  }
844 
845  g_edicts = gi.TagMalloc(game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
846  globals.edicts = g_edicts;
847  globals.max_edicts = game.maxentities;
848 
849  game.clients = gi.TagMalloc(game.maxclients * sizeof(game.clients[0]), TAG_GAME);
850  for (i = 0; i < game.maxclients; i++) {
852  }
853 
854  fclose(f);
855 }

Referenced by GetGameAPI().

◆ ReadLevel()

void ReadLevel ( const char *  filename)

Definition at line 912 of file g_save.c.

913 {
914  int entnum;
915  FILE *f;
916  int i;
917  edict_t *ent;
918 
919  // free any dynamic memory allocated by loading the level
920  // base state
921  gi.FreeTags(TAG_LEVEL);
922 
923  f = fopen(filename, "rb");
924  if (!f)
925  gi.error("Couldn't open %s", filename);
926 
927  // wipe all the entities
928  memset(g_edicts, 0, game.maxentities * sizeof(g_edicts[0]));
929  globals.num_edicts = maxclients->value + 1;
930 
931  i = read_int(f);
932  if (i != SAVE_MAGIC2) {
933  fclose(f);
934  gi.error("Not a save game");
935  }
936 
937  i = read_int(f);
938  if (i != SAVE_VERSION) {
939  fclose(f);
940  gi.error("Savegame from an older version");
941  }
942 
943  // load the level locals
945 
946  // load all the entities
947  while (1) {
948  entnum = read_int(f);
949  if (entnum == -1)
950  break;
951  if (entnum < 0 || entnum >= game.maxentities) {
952  gi.error("%s: bad entity number", __func__);
953  }
954  if (entnum >= globals.num_edicts)
955  globals.num_edicts = entnum + 1;
956 
957  ent = &g_edicts[entnum];
958  read_fields(f, entityfields, ent);
959  ent->inuse = qtrue;
960  ent->s.number = entnum;
961 
962  // let the server rebuild world links for this ent
963  memset(&ent->area, 0, sizeof(ent->area));
964  gi.linkentity(ent);
965  }
966 
967  fclose(f);
968 
969  // mark all clients as unconnected
970  for (i = 0 ; i < maxclients->value ; i++) {
971  ent = &g_edicts[i + 1];
972  ent->client = game.clients + i;
973  ent->client->pers.connected = qfalse;
974  }
975 
976  // do any load time things at this point
977  for (i = 0 ; i < globals.num_edicts ; i++) {
978  ent = &g_edicts[i];
979 
980  if (!ent->inuse)
981  continue;
982 
983  // fire any cross-level triggers
984  if (ent->classname)
985  if (strcmp(ent->classname, "target_crosslevel_target") == 0)
986  ent->nextthink = level.time + ent->delay;
987 
988  if (ent->think == func_clock_think || ent->use == func_clock_use) {
989  char *msg = ent->message;
990  ent->message = gi.TagMalloc(CLOCK_MESSAGE_SIZE, TAG_LEVEL);
991  if (msg) {
992  Q_strlcpy(ent->message, msg, CLOCK_MESSAGE_SIZE);
993  gi.TagFree(msg);
994  }
995  }
996  }
997 }

Referenced by GetGameAPI().

◆ write_data()

static void write_data ( void buf,
size_t  len,
FILE *  f 
)
static

Definition at line 433 of file g_save.c.

434 {
435  if (fwrite(buf, 1, len, f) != len) {
436  gi.error("%s: couldn't write %"PRIz" bytes", __func__, len);
437  }
438 }

Referenced by write_field(), write_float(), write_int(), write_short(), and write_string().

◆ write_field()

static void write_field ( FILE *  f,
const save_field_t field,
void base 
)
static

Definition at line 519 of file g_save.c.

520 {
521  void *p = (byte *)base + field->ofs;
522  int i;
523 
524  switch (field->type) {
525  case F_BYTE:
526  write_data(p, field->size, f);
527  break;
528  case F_SHORT:
529  for (i = 0; i < field->size; i++) {
530  write_short(f, ((short *)p)[i]);
531  }
532  break;
533  case F_INT:
534  for (i = 0; i < field->size; i++) {
535  write_int(f, ((int *)p)[i]);
536  }
537  break;
538  case F_FLOAT:
539  for (i = 0; i < field->size; i++) {
540  write_float(f, ((float *)p)[i]);
541  }
542  break;
543  case F_VECTOR:
544  write_vector(f, (vec_t *)p);
545  break;
546 
547  case F_ZSTRING:
548  write_string(f, (char *)p);
549  break;
550  case F_LSTRING:
551  write_string(f, *(char **)p);
552  break;
553 
554  case F_EDICT:
555  write_index(f, *(void **)p, sizeof(edict_t), g_edicts, MAX_EDICTS - 1);
556  break;
557  case F_CLIENT:
558  write_index(f, *(void **)p, sizeof(gclient_t), game.clients, game.maxclients - 1);
559  break;
560  case F_ITEM:
561  write_index(f, *(void **)p, sizeof(gitem_t), itemlist, game.num_items - 1);
562  break;
563 
564  case F_POINTER:
565  write_pointer(f, *(void **)p, field->size);
566  break;
567 
568  default:
569  gi.error("%s: unknown field type", __func__);
570  }
571 }

Referenced by write_fields().

◆ write_fields()

static void write_fields ( FILE *  f,
const save_field_t fields,
void base 
)
static

Definition at line 573 of file g_save.c.

574 {
575  const save_field_t *field;
576 
577  for (field = fields; field->type; field++) {
578  write_field(f, field, base);
579  }
580 }

Referenced by WriteGame(), and WriteLevel().

◆ write_float()

static void write_float ( FILE *  f,
float  v 
)
static

Definition at line 452 of file g_save.c.

453 {
454  v = LittleFloat(v);
455  write_data(&v, sizeof(v), f);
456 }

Referenced by write_field(), and write_vector().

◆ 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.

480 {
481  size_t diff;
482 
483  if (!p) {
484  write_int(f, -1);
485  return;
486  }
487 
488  if (p < start || (byte *)p > (byte *)start + max_index * size) {
489  gi.error("%s: pointer out of range: %p", __func__, p);
490  }
491 
492  diff = (byte *)p - (byte *)start;
493  if (diff % size) {
494  gi.error("%s: misaligned pointer: %p", __func__, p);
495  }
496  write_int(f, (int)(diff / size));
497 }

Referenced by write_field().

◆ write_int()

static void write_int ( FILE *  f,
int  v 
)
static

Definition at line 446 of file g_save.c.

447 {
448  v = LittleLong(v);
449  write_data(&v, sizeof(v), f);
450 }

Referenced by write_field(), write_index(), write_pointer(), write_string(), WriteGame(), and WriteLevel().

◆ write_pointer()

static void write_pointer ( FILE *  f,
void p,
ptr_type_t  type 
)
static

Definition at line 499 of file g_save.c.

500 {
501  const save_ptr_t *ptr;
502  int i;
503 
504  if (!p) {
505  write_int(f, -1);
506  return;
507  }
508 
509  for (i = 0, ptr = save_ptrs; i < num_save_ptrs; i++, ptr++) {
510  if (ptr->type == type && ptr->ptr == p) {
511  write_int(f, i);
512  return;
513  }
514  }
515 
516  gi.error("%s: unknown pointer: %p", __func__, p);
517 }

Referenced by write_field().

◆ write_short()

static void write_short ( FILE *  f,
short  v 
)
static

Definition at line 440 of file g_save.c.

441 {
442  v = LittleShort(v);
443  write_data(&v, sizeof(v), f);
444 }

Referenced by write_field().

◆ write_string()

static void write_string ( FILE *  f,
char *  s 
)
static

Definition at line 458 of file g_save.c.

459 {
460  size_t len;
461 
462  if (!s) {
463  write_int(f, -1);
464  return;
465  }
466 
467  len = strlen(s);
468  write_int(f, len);
469  write_data(s, len, f);
470 }

Referenced by write_field().

◆ write_vector()

static void write_vector ( FILE *  f,
vec_t *  v 
)
static

Definition at line 472 of file g_save.c.

473 {
474  write_float(f, v[0]);
475  write_float(f, v[1]);
476  write_float(f, v[2]);
477 }

Referenced by write_field().

◆ WriteGame()

void WriteGame ( const char *  filename,
qboolean  autosave 
)

Definition at line 784 of file g_save.c.

785 {
786  FILE *f;
787  int i;
788 
789  if (!autosave)
790  SaveClientData();
791 
792  f = fopen(filename, "wb");
793  if (!f)
794  gi.error("Couldn't open %s", filename);
795 
798 
799  game.autosaved = autosave;
801  game.autosaved = qfalse;
802 
803  for (i = 0; i < game.maxclients; i++) {
805  }
806 
807  fclose(f);
808 }

Referenced by GetGameAPI().

◆ WriteLevel()

void WriteLevel ( const char *  filename)

Definition at line 866 of file g_save.c.

867 {
868  int i;
869  edict_t *ent;
870  FILE *f;
871 
872  f = fopen(filename, "wb");
873  if (!f)
874  gi.error("Couldn't open %s", filename);
875 
878 
879  // write out level_locals_t
881 
882  // write out all the entities
883  for (i = 0; i < globals.num_edicts; i++) {
884  ent = &g_edicts[i];
885  if (!ent->inuse)
886  continue;
887  write_int(f, i);
888  write_fields(f, entityfields, ent);
889  }
890  write_int(f, -1);
891 
892  fclose(f);
893 }

Referenced by GetGameAPI().

Variable Documentation

◆ clientfields

const save_field_t clientfields[]
static

Definition at line 292 of file g_save.c.

Referenced by ReadGame(), and WriteGame().

◆ entityfields

const save_field_t entityfields[]
static

Definition at line 53 of file g_save.c.

Referenced by ReadLevel(), and WriteLevel().

◆ gamefields

const save_field_t gamefields[]
static
Initial value:
= {
#define _OFS
SZ(helpmessage1, 512),
SZ(helpmessage2, 512),
I(serverflags),
I(num_items),
I(autosaved),
{0}
}

Definition at line 413 of file g_save.c.

Referenced by ReadGame(), and WriteGame().

◆ levelfields

const save_field_t levelfields[]
static

Definition at line 249 of file g_save.c.

Referenced by ReadLevel(), and WriteLevel().

gi
game_import_t gi
Definition: g_main.c:23
write_int
static void write_int(FILE *f, int v)
Definition: g_save.c:446
read_index
static void * read_index(FILE *f, size_t size, void *start, int max_index)
Definition: g_save.c:661
save_field_t::size
size_t size
Definition: g_save.c:29
save_ptr_t
Definition: g_ptrs.h:27
maxclients
cvar_t * maxclients
Definition: g_main.c:42
F_ZSTRING
@ F_ZSTRING
Definition: g_local.h:573
write_vector
static void write_vector(FILE *f, vec_t *v)
Definition: g_save.c:472
write_data
static void write_data(void *buf, size_t len, FILE *f)
Definition: g_save.c:433
F_VECTOR
@ F_VECTOR
Definition: g_local.h:574
write_fields
static void write_fields(FILE *f, const save_field_t *fields, void *base)
Definition: g_save.c:573
F_BYTE
@ F_BYTE
Definition: g_local.h:567
write_short
static void write_short(FILE *f, short v)
Definition: g_save.c:440
read_int
static int read_int(FILE *f)
Definition: g_save.c:599
write_field
static void write_field(FILE *f, const save_field_t *field, void *base)
Definition: g_save.c:519
maxentities
cvar_t * maxentities
Definition: g_main.c:44
TAG_LEVEL
#define TAG_LEVEL
Definition: g_local.h:79
save_ptr_t::ptr
void * ptr
Definition: g_ptrs.h:29
F_ITEM
@ F_ITEM
Definition: g_local.h:577
g_edicts
edict_t * g_edicts
Definition: g_main.c:31
F_EDICT
@ F_EDICT
Definition: g_local.h:576
itemlist
gitem_t itemlist[]
Definition: g_items.c:1063
save_ptrs
const save_ptr_t save_ptrs[]
Definition: g_ptrs.c:619
clientfields
static const save_field_t clientfields[]
Definition: g_save.c:292
F_FLOAT
@ F_FLOAT
Definition: g_local.h:570
write_pointer
static void write_pointer(FILE *f, void *p, ptr_type_t type)
Definition: g_save.c:499
read_field
static void read_field(FILE *f, const save_field_t *field, void *base)
Definition: g_save.c:701
read_string
static char * read_string(FILE *f)
Definition: g_save.c:620
write_string
static void write_string(FILE *f, char *s)
Definition: g_save.c:458
F_CLIENT
@ F_CLIENT
Definition: g_local.h:578
CLOCK_MESSAGE_SIZE
#define CLOCK_MESSAGE_SIZE
Definition: g_local.h:692
read_zstring
static void read_zstring(FILE *f, char *s, size_t size)
Definition: g_save.c:641
SAVE_VERSION
#define SAVE_VERSION
Definition: g_save.c:768
game_locals_t::num_items
int num_items
Definition: g_local.h:287
save_field_t::ofs
size_t ofs
Definition: g_save.c:28
game_locals_t::clients
gclient_t * clients
Definition: g_local.h:273
game
game_locals_t game
Definition: g_main.c:21
I
#define I(name)
Definition: g_save.c:44
globals
game_export_t globals
Definition: g_main.c:24
write_float
static void write_float(FILE *f, float v)
Definition: g_save.c:452
Q_strlcpy
size_t Q_strlcpy(char *dst, const char *src, size_t size)
Definition: shared.c:715
save_field_t
Definition: g_save.c:23
F_SHORT
@ F_SHORT
Definition: g_local.h:568
gamefields
static const save_field_t gamefields[]
Definition: g_save.c:413
entityfields
static const save_field_t entityfields[]
Definition: g_save.c:53
save_ptr_t::type
ptr_type_t type
Definition: g_ptrs.h:28
game_locals_t::autosaved
qboolean autosaved
Definition: g_local.h:289
level_locals_t::time
float time
Definition: g_local.h:299
read_vector
static void read_vector(FILE *f, vec_t *v)
Definition: g_save.c:654
save_field_t::type
fieldtype_t type
Definition: g_save.c:24
TAG_GAME
#define TAG_GAME
Definition: g_local.h:78
level
level_locals_t level
Definition: g_main.c:22
diff
static q_noinline int diff(uint32_t A_u32, uint32_t B_u32)
Definition: hq2x.c:55
SAVE_MAGIC2
#define SAVE_MAGIC2
Definition: g_save.c:767
num_save_ptrs
const int num_save_ptrs
Definition: g_ptrs.c:1237
msg
const char * msg
Definition: win.h:25
func_clock_use
void func_clock_use(edict_t *self, edict_t *other, edict_t *activator)
Definition: g_misc.c:1660
read_float
static float read_float(FILE *f)
Definition: g_save.c:609
write_index
static void write_index(FILE *f, void *p, size_t size, void *start, int max_index)
Definition: g_save.c:479
read_data
static void read_data(void *buf, size_t len, FILE *f)
Definition: g_save.c:582
func_clock_think
void func_clock_think(edict_t *self)
Definition: g_misc.c:1600
F_LSTRING
@ F_LSTRING
Definition: g_local.h:571
read_short
static int read_short(FILE *f)
Definition: g_save.c:589
SaveClientData
void SaveClientData(void)
Definition: p_client.c:635
game_locals_t::maxentities
int maxentities
Definition: g_local.h:281
SAVE_MAGIC1
#define SAVE_MAGIC1
Definition: g_save.c:766
F_POINTER
@ F_POINTER
Definition: g_local.h:580
levelfields
static const save_field_t levelfields[]
Definition: g_save.c:249
F_INT
@ F_INT
Definition: g_local.h:569
read_pointer
static void * read_pointer(FILE *f, ptr_type_t type)
Definition: g_save.c:679
SZ
#define SZ(name, size)
Definition: g_save.c:38
read_fields
static void read_fields(FILE *f, const save_field_t *fields, void *base)
Definition: g_save.c:755
gitem_s
Definition: g_local.h:232
game_locals_t::maxclients
int maxclients
Definition: g_local.h:280