Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Snipes

This is a modern port of the classic 1982 text-mode game Snipes. The code has been reverse-engineered from the original DOS executable, and has 100% identical game logic.
This is a modern port of the classic 1982 text-mode game Snipes. The code has been reverse-engineered from the original DOS executable, and has 100% identical game logic.

For more information, see the [vogons.org forum thread](https://www.vogons.org/viewtopic.php?f=7&t=49073).

Expand Down Expand Up @@ -28,6 +28,7 @@ For Arch Linux, you can use the [snipes-git](https://aur.archlinux.org/packages/
### Replay recording

This version automatically records replay files of played games. By default, replay files are saved to the current directory, and have a `.SnipesGame` file extension.
If you uncomment the `#define REPLAY_FOLDER` line in config.h and enter a valid path, the `.SnipesGame` replays will be saved to that directory rather than the current directory.

To play back a replay file, pass it as the first argument to the game program, e.g.:

Expand Down
28 changes: 24 additions & 4 deletions Snipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
#include "keyboard.h"
#include "platform.h"


// Platform-specific directory creation
#if defined(_WIN32) || defined(_WIN64)
#include <direct.h>
#define CREATE_DIRECTORY(path) _mkdir(path)
#else
#include <sys/stat.h>
#include <sys/types.h>
#define CREATE_DIRECTORY(path) mkdir(path, 0755)
#endif

//IF REPLAY_FOLDER is not defined, it should use the current folder.
#ifndef REPLAY_FOLDER
#define REPLAY_FOLDER "."
#endif

bool got_ctrl_break = false;
bool forfeit_match = false;
bool instant_quit = false;
Expand Down Expand Up @@ -1733,7 +1749,7 @@ void EraseObjectFromMaze()
}
}

//template <typename TYPE> TYPE &IncWrap(TYPE &n,
//template <typename TYPE> TYPE &IncWrap(TYPE &n,

void UpdateSnipePortals()
{
Expand Down Expand Up @@ -2271,9 +2287,13 @@ extern "C" int __cdecl SDL_main(int argc, char* argv[])
struct tm *rectime_gmt;
rectime_gmt = gmtime(&rectime);

char replayFilename[1024];
sprintf(replayFilename,
"%04d-%02d-%02d %02d.%02d.%02d.SnipesGame",
// Create the replay folder if it doesn't exist
CREATE_DIRECTORY(REPLAY_FOLDER);

char replayFilename[1024];
snprintf(replayFilename, sizeof(replayFilename),
"%s/%04d-%02d-%02d %02d.%02d.%02d.SnipesGame",
REPLAY_FOLDER,
1900+rectime_gmt->tm_year, rectime_gmt->tm_mon+1, rectime_gmt->tm_mday,
rectime_gmt->tm_hour, rectime_gmt->tm_min, rectime_gmt->tm_sec);

Expand Down
8 changes: 8 additions & 0 deletions config-sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
// For playback: Wait for a keypress at start, and behave like a live game at end. Meant for screen recording of a played back replay.
//#define PLAYBACK_FOR_SCREEN_RECORDING

// Store Recording files to a single folder.
// This should ensure playback that the game doesn't develop a __MACOSX problem where there are SnipesGameFiles littered everywhere.
// For Linux: (note, you can't use the ~/SnipesGameFiles naming format)
#define REPLAY_FOLDER "/home/username/SnipesGameFiles"
//
// For Windows:
// #define PLAYBACKFOLDER "C:\SnipesGameFiles"

// Windows options
#define WINDOWS_PRECISE_TIMER

Expand Down