Add endian converter for demos, read shareware demos, various bugfixes to demo system

This commit is contained in:
kreatordxx 2009-11-15 08:22:08 +00:00
parent 70bbac21b7
commit d57c2981c2
6 changed files with 1000 additions and 568 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20091115
--------
main/gamecntl.c, main/newdemo.c, main/newdemo.h, main/newmenu.c, main/text.c: Add endian converter for demos, read shareware demos, various bugfixes to demo system
20091005
--------
d1x-rebirth.xcodeproj/project.pbxproj, include/physfsx.h, main/ai.c, main/ai.h, main/cntrlcen.c, main/cntrlcen.h, main/fuelcen.c, main/fuelcen.h, main/object.c, main/object.h, main/player.c, main/player.h, main/state.c, main/switch.c, main/switch.h, main/wall.c, main/wall.h, SConstruct: Read big endian savegames on little endian computers and vice versa

View file

@ -442,7 +442,7 @@ void HandleDemoKey(int key)
Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
break;
case KEY_CTRLED + KEY_RIGHT:
newdemo_goto_end();
newdemo_goto_end(0);
break;
case KEY_CTRLED + KEY_LEFT:
newdemo_goto_beginning();

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,4 @@
/* $Id: newdemo.h,v 1.1.1.1 2006/03/17 19:57:04 zicodxx Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -10,12 +11,14 @@ CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
*
* .
* header for demo playback system
*
*/
#ifndef _NEWDEMO_H
#define _NEWDEMO_H
@ -29,6 +32,11 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define ND_STATE_ONEFRAMEBACKWARD 7
#define DEMO_DIR "demos/"
#if WORDS_BIGENDIAN
#define DEMO_BACKUP_EXT "386"
#else
#define DEMO_BACKUP_EXT "ppc"
#endif
// Gives state of recorder
extern int Newdemo_state;
@ -56,13 +64,8 @@ extern void newdemo_record_wall_toggle(int segnum, int side );
extern void newdemo_record_control_center_destroyed();
extern void newdemo_record_hud_message(char *s);
extern void newdemo_record_palette_effect(short r, short g, short b);
#ifdef SHAREWARE
extern void newdemo_record_player_energy(int);
extern void newdemo_record_player_shields(int);
#else
extern void newdemo_record_player_energy(int, int);
extern void newdemo_record_player_shields(int, int);
#endif
extern void newdemo_record_player_flags(uint, uint);
extern void newdemo_record_player_weapon(int, int);
extern void newdemo_record_effect_blowup(short, int, vms_vector *);
@ -77,7 +80,6 @@ extern void newdemo_record_multi_decloak(int pnum);
extern void newdemo_set_new_level(int level_num);
extern void newdemo_record_restore_rearview(void);
#ifndef SHAREWARE
extern void newdemo_record_multi_death(int pnum);
extern void newdemo_record_multi_kill(int pnum, sbyte kill);
extern void newdemo_record_multi_connect(int pnum, int new_player, char *new_callsign);
@ -88,14 +90,12 @@ extern void newdemo_record_multi_score(int pnum, int score);
extern void newdemo_record_primary_ammo(int old_ammo, int new_ammo);
extern void newdemo_record_secondary_ammo(int old_ammo, int new_ammo);
extern void newdemo_record_door_opening(int segnum, int side);
#endif
extern void newdemo_record_laser_level(sbyte old_level, sbyte new_level);
// Functions called during playback process...
extern void newdemo_object_move_all();
extern void newdemo_playback_one_frame();
extern void newdemo_goto_end();
extern void newdemo_goto_end(int to_rewrite);
extern void newdemo_goto_beginning();
// Interactive functions to control playback/record;
@ -104,9 +104,12 @@ extern void newdemo_stop_playback();
extern void newdemo_start_recording();
extern void newdemo_stop_recording();
extern int newdemo_swap_endian(char *filename);
extern int newdemo_get_percent_done();
extern void newdemo_record_link_sound_to_object3( int soundno, short objnum, fix max_volume, fix max_distance, int loop_start, int loop_end );
extern int newdemo_find_object( int signature );
extern void newdemo_record_kill_sound_linked_to_object( int objnum );
#endif
#endif // _NEWDEMO_H

View file

@ -17,7 +17,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -29,15 +28,15 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include <physfs/physfs.h>
#endif
#include "error.h"
#include "pstypes.h"
#include "error.h"
#include "gr.h"
#include "songs.h"
#include "key.h"
#include "palette.h"
#include "game.h"
#include "text.h"
#include "newdemo.h"
#include "menu.h"
#include "newmenu.h"
#include "gamefont.h"
#include "iff.h"
@ -49,13 +48,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "multi.h"
#include "endlevel.h"
#include "screens.h"
#include "kconfig.h"
#include "player.h"
#include "timer.h"
#include "newdemo.h"
#include "kconfig.h"
#include "vers_id.h"
#include "automap.h"
#include "menu.h"
#include "timer.h"
#include "playsave.h"
#include "automap.h"
#include "rbaudio.h"
#ifdef OGL
@ -1701,6 +1700,26 @@ ReadFileNames:
}
}
break;
case KEY_CTRLED+KEY_C:
if (demo_mode)
{
int x = 1;
char bakname[PATH_MAX];
// Get backup .bak name
change_filename_extension(bakname, &filenames[citem*(FILENAME_LEN+1)]+((demo_mode && filenames[citem*(FILENAME_LEN+1)]=='$')?1:0), "bak");
x = nm_messagebox( NULL, 2, TXT_YES, TXT_NO, "Are you sure you want to\n"
"swap the endianness of\n"
"%s? If the file is\n"
"already endian native, D1X\n"
"will likely crash. A backup\n"
"%s will be created", &filenames[citem*(FILENAME_LEN+1)]+((demo_mode && filenames[citem*(FILENAME_LEN+1)]=='$')?1:0), bakname );
if (x)
break;
newdemo_swap_endian(&filenames[citem*(FILENAME_LEN+1)]);
}
break;
case KEY_HOME:
case KEY_PAD7:
citem = 0;

View file

@ -1,3 +1,4 @@
/* $Id: text.c,v 1.1.1.1 2006/03/17 19:56:37 zicodxx Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -10,22 +11,21 @@ CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
*
* Code for localizable text
*
*/
#ifdef RCS
static char rcsid[] = "$Id: text.c,v 1.1.1.1 2006/03/17 19:43:44 zicodxx Exp $";
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "cfile.h"
#include "pstypes.h"
#include "cfile.h"
#include "u_mem.h"
#include "error.h"
@ -33,11 +33,9 @@ static char rcsid[] = "$Id: text.c,v 1.1.1.1 2006/03/17 19:43:44 zicodxx Exp $";
#include "inferno.h"
#include "text.h"
#include "args.h"
#include "compbit.h"
char *text;
char *Text_string[N_TEXT_STRINGS];
void free_text()
@ -45,6 +43,7 @@ void free_text()
//added on 9/13/98 by adb to free all text
d_free(Text_string[145]);
//end addition - adb
d_free(Text_string[330]);
d_free(text);
}
@ -214,8 +213,10 @@ void load_text()
if ((tfile = cfopen(filename,"rb")) == NULL) {
filename="descent.txb";
if ((ifile = cfopen(filename, "rb")) == NULL)
if ((ifile = cfopen(filename, "rb")) == NULL) {
Error("Cannot open file DESCENT.TEX or DESCENT.TXB");
return;
}
have_binary = 1;
len = cfilelength(ifile);
@ -279,17 +280,12 @@ void load_text()
if ( tptr ) *tptr++ = 0;
if (have_binary) {
for (p=Text_string[i]; p < tptr - 1; p++) {
encode_rotate_left(p);
*p = *p ^ BITMAP_TBL_XOR;
encode_rotate_left(p);
}
}
if (have_binary)
decode_text_line(Text_string[i]);
//scan for special chars (like \n)
for (p=Text_string[i];(p=strchr(p,'\\'));) {
char newchar=0;//get rid of compiler warning
char newchar;
if (p[1] == 'n') newchar = '\n';
else if (p[1] == 't') newchar = '\t';
@ -302,19 +298,33 @@ void load_text()
MALLOC(buf,char,len+1);
strcpy(buf,p+2);
strcpy(p+1,buf);
p++;
d_free(buf);
p++;
}
switch(i) {
char *extra;
char *str;
case 145:
Text_string[i]=(char *) d_malloc(sizeof(char) * 48);
strcpy(Text_string[i],"Sidewinder &\nThrustmaster FCS &\nWingman Extreme");
break;
case 330:
extra = "\n<Ctrl+C> converts format\nIntel <-> PowerPC";
str = d_malloc(strlen(Text_string[i]) + strlen(extra) + 1);
if (!str)
break;
strcpy(str, Text_string[i]);
strcat(str, extra);
Text_string[i] = str;
break;
}
}
// Assert(tptr==text+len || tptr==text+len-2);
//Assert(tptr==text+len || tptr==text+len-2);
}