Created header for MAKE_SIG macro

This commit is contained in:
Bradley Bell 2001-11-11 23:39:22 +00:00
parent 9a270994d6
commit 9040140f58
2 changed files with 38 additions and 7 deletions

18
include/makesig.h Normal file
View file

@ -0,0 +1,18 @@
/*
* $Source: /cvs/cvsroot/d2x/include/makesig.h,v $
* $Revision: 1.1 $
* $Author: bradleyb $
* $Date: 2001-11-11 23:39:22 $
*
* Macro to make file signatures
*
* $Log: not supported by cvs2svn $
*
*/
#ifndef _MAKESIG_H
#define _MAKESIG_H
#define MAKE_SIG(a,b,c,d) (((long)(a)<<24)+((long)(b)<<16)+((c)<<8)+(d))
#endif

View file

@ -11,8 +11,21 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/ */
#include <conf.h> /*
* $Source: /cvs/cvsroot/d2x/main/playsave.c,v $
* $Revision: 1.3 $
* $Author: bradleyb $
* $Date: 2001-11-11 23:39:22 $
*
* Functions to load & save player games
*
* $Log: not supported by cvs2svn $
*
*/
#ifdef HAVE_CONFIG_H
#include <conf.h>
#endif
#ifdef WINDOWS #ifdef WINDOWS
#include "desw.h" #include "desw.h"
@ -47,8 +60,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "gauges.h" #include "gauges.h"
#include "screens.h" #include "screens.h"
#include "powerup.h" #include "powerup.h"
#include "makesig.h"
#define SAVE_FILE_ID "DPLR" #define SAVE_FILE_ID MAKE_SIG('D','P','L','R')
#ifdef MACINTOSH #ifdef MACINTOSH
#include <Files.h> #include <Files.h>
@ -353,9 +367,8 @@ int read_player_file()
#endif #endif
FILE *file; FILE *file;
int errno_ret = EZERO; int errno_ret = EZERO;
int player_file_version,i; int id,player_file_version,i;
int rewrite_it=0; int rewrite_it=0;
char id[4];
Assert(Player_num>=0 && Player_num<MAX_PLAYERS); Assert(Player_num>=0 && Player_num<MAX_PLAYERS);
@ -380,9 +393,9 @@ int read_player_file()
return errno; return errno;
} }
fread( &id, 1, 4, file); id = read_int(file);
if (memcmp(id, SAVE_FILE_ID, 4)) { if (id!=SAVE_FILE_ID) {
nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid player file"); nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid player file");
fclose(file); fclose(file);
return -1; return -1;
@ -669,7 +682,7 @@ int write_player_file()
errno_ret = EZERO; errno_ret = EZERO;
//Write out player's info //Write out player's info
fwrite(SAVE_FILE_ID, 1, 4, file); write_int(SAVE_FILE_ID,file);
write_short(PLAYER_FILE_VERSION,file); write_short(PLAYER_FILE_VERSION,file);
write_short(Game_window_w,file); write_short(Game_window_w,file);