-
Notifications
You must be signed in to change notification settings - Fork 10
/
mdlfun.cpp
70 lines (58 loc) · 1.36 KB
/
mdlfun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// mdlfun.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <boost/process.hpp>
#include <boost/dll.hpp>
#include <string>
#include "funcs.h"
#include "dung.h"
#include "rooms.h"
#include "version.h"
std::string pw(SIterator unm, SIterator key);
std::string username();
using namespace std::string_view_literals;
int run_zork()
{
// Option to print incantation to skip directly to the endgame.
#if 0
std::string un = username();
std::string hello("HELLO");
std::cerr << "Hello : " << pw(un, hello) << std::endl;
#endif
init_dung();
tell("ZORK++ version "sv + sVersion);
save_it(true);
bool restart = false;
try
{
rdcom();
}
catch (ExitException &e)
{
restart = e.restart_flag();
}
return restart;
}
int main(int argc, char *argv[])
{
int rv = 0;
if (argc == 1)
{
intptr_t status = 1;
// If no arguments are passed, spawn the same process
// with the "-go" parameter. This allows restarts to
// happen easily. If the child process returns 1,
// a restart will occur. If it returns 0 the shell will
// exit.
while (status == 1)
{
auto path = boost::dll::program_location().string();
status = boost::process::system(path + " -go");
}
}
else
{
rv = run_zork();
}
return rv;
}