• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision9167de6a345c336c61a8fb490449839d69fcfa33 (tree)
Time2020-03-16 19:08:05
Authorshimitei <shimitei@gmai...>
Commitershimitei

Log Message

main for now

Change Summary

Incremental Difference

--- /dev/null
+++ b/src/main-wasm.c
@@ -0,0 +1,149 @@
1+/* File: main-wasm.c */
2+
3+/*
4+ * Copyright (c) 1997 Ben Harrison, and others
5+ *
6+ * This software may be copied and distributed for educational, research,
7+ * and not for profit purposes provided that this copyright and statement
8+ * are included in all such copies.
9+ */
10+
11+#include "angband.h"
12+
13+
14+/*
15+ * A hook for "quit()".
16+ *
17+ * Close down, then fall back into "quit()".
18+ */
19+static void quit_hook(concptr s)
20+{
21+ int j;
22+
23+ /* Unused */
24+ (void)s;
25+
26+ /* Scan windows */
27+ for (j = 8 - 1; j >= 0; j--)
28+ {
29+ /* Unused */
30+ if (!angband_term[j]) continue;
31+
32+ /* Nuke it */
33+ term_nuke(angband_term[j]);
34+ }
35+}
36+
37+
38+/*
39+ * Initialize and verify the file paths, and the score file.
40+ *
41+ * Use the ANGBAND_PATH environment var if possible, else use
42+ * DEFAULT_(LIB|VAR)_PATH, and in either case, branch off
43+ * appropriately.
44+ *
45+ * First, we'll look for the ANGBAND_PATH environment variable,
46+ * and then look for the files in there. If that doesn't work,
47+ * we'll try the DEFAULT_(LIB|VAR)_PATH constants. So be sure
48+ * that one of these two things works...
49+ *
50+ * We must ensure that the path ends with "PATH_SEP" if needed,
51+ * since the "init_file_paths()" function will simply append the
52+ * relevant "sub-directory names" to the given path.
53+ *
54+ * Make sure that the path doesn't overflow the buffer. We have
55+ * to leave enough space for the path separator, directory, and
56+ * filenames.
57+ */
58+static void init_stuff(void)
59+{
60+ char libpath[1024], varpath[1024];
61+
62+ concptr tail;
63+
64+ /* Get the environment variable */
65+ tail = getenv("ANGBAND_PATH");
66+
67+ /* Use the angband_path, or a default */
68+ strncpy(libpath, tail ? tail : DEFAULT_LIB_PATH, 511);
69+ strncpy(varpath, tail ? tail : DEFAULT_VAR_PATH, 511);
70+
71+ /* Make sure they're terminated */
72+ libpath[511] = '\0';
73+ varpath[511] = '\0';
74+
75+ /* Hack -- Add a path separator (only if needed) */
76+ if (!suffix(libpath, PATH_SEP)) strcat(libpath, PATH_SEP);
77+ if (!suffix(varpath, PATH_SEP)) strcat(varpath, PATH_SEP);
78+
79+ /* Initialize */
80+ init_file_paths(libpath, varpath);
81+}
82+
83+
84+/*
85+ * Simple "main" function for multiple platforms.
86+ *
87+ */
88+int main(int argc, char *argv[])
89+{
90+ bool done = FALSE;
91+ bool new_game = TRUE;
92+
93+ /* Get the file paths */
94+ init_stuff();
95+
96+ /* Process the player name */
97+ process_player_name(TRUE);
98+
99+ /* Install "quit" hook */
100+ quit_aux = quit_hook;
101+
102+
103+#ifdef USE_GCU
104+ /* Attempt to use the "main-gcu.c" support */
105+ if (!done)
106+ {
107+ extern errr init_gcu(int, char**);
108+ if (0 == init_gcu(argc, argv))
109+ {
110+ ANGBAND_SYS = "gcu";
111+ done = TRUE;
112+ }
113+ }
114+#endif
115+
116+#ifdef USE_CAP
117+ /* Attempt to use the "main-cap.c" support */
118+ if (!done)
119+ {
120+ extern errr init_cap(int, char**);
121+ if (0 == init_cap(argc, argv))
122+ {
123+ ANGBAND_SYS = "cap";
124+ done = TRUE;
125+ }
126+ }
127+#endif
128+
129+ /* Make sure we have a display! */
130+ if (!done) quit("Unable to prepare any 'display module'!");
131+
132+ /* Catch nasty signals */
133+ signals_init();
134+
135+ /* Initialize */
136+ init_angband();
137+
138+ /* Wait for response */
139+ pause_line(23);
140+
141+ /* Play the game */
142+ play_game(new_game);
143+
144+ /* Quit */
145+ quit(NULL);
146+
147+ /* Exit */
148+ return (0);
149+}