Mercurial > hg > forks > yadex
annotate src/yadex.cc @ 83:002bc70a3982
More cleanups. Mostly variable renames.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 26 Sep 2011 18:06:30 +0300 |
parents | 154714f3ab2e |
children | c518e08d5961 |
rev | line source |
---|---|
0 | 1 /* |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
2 * yadex.cc |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
3 * The main module. |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
4 * BW & RQ sometime in 1993 or 1994. |
0 | 5 */ |
6 | |
7 | |
8 /* | |
9 This file is part of Yadex. | |
10 | |
11 Yadex incorporates code from DEU 5.21 that was put in the public domain in | |
12 1994 by Raphaël Quinet and Brendon Wyber. | |
13 | |
14 The rest of Yadex is Copyright © 1997-2003 André Majorel and others. | |
15 | |
16 This program is free software; you can redistribute it and/or modify it under | |
17 the terms of the GNU General Public License as published by the Free Software | |
18 Foundation; either version 2 of the License, or (at your option) any later | |
19 version. | |
20 | |
21 This program is distributed in the hope that it will be useful, but WITHOUT | |
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
23 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
24 | |
25 You should have received a copy of the GNU General Public License along with | |
26 this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
27 Place, Suite 330, Boston, MA 02111-1307, USA. | |
28 */ | |
29 | |
30 | |
31 #include "yadex.h" | |
32 #include <time.h> | |
33 #include "acolours.h" | |
34 #include "bench.h" | |
35 #include "cfgfile.h" | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
36 #include "disppic.h" /* Because of "p" */ |
0 | 37 #include "editlev.h" |
38 #include "endian.h" | |
39 #include "flats.h" | |
40 #include "game.h" | |
41 #include "gfx.h" | |
42 #include "help1.h" | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
43 #include "levels.h" /* Because of "viewtex" */ |
0 | 44 #include "lists.h" |
45 #include "mkpalette.h" | |
46 #include "palview.h" | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
47 #include "patchdir.h" /* Because of "p" */ |
0 | 48 #include "rgb.h" |
49 #include "sanity.h" | |
50 #include "textures.h" | |
51 #include "x11.h" | |
52 #include "wadfile.h" | |
53 #include "wadlist.h" | |
54 #include "wadname.h" | |
55 #include "wadres.h" | |
56 #include "wads2.h" | |
57 | |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
58 #ifdef Y_READLINE |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
59 #include <readline/readline.h> |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
60 #include <readline/history.h> |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
61 #endif |
0 | 62 |
63 | |
64 | |
65 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
66 * Global variables |
0 | 67 */ |
82
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
68 const char *const yadex_log_filename = "yadex.log"; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
69 |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
70 yglf_t yg_level_format = YGLF__; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
71 ygln_t yg_level_name = YGLN__; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
72 ygpf_t yg_picture_format = YGPF_NORMAL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
73 ygtf_t yg_texture_format = YGTF_NORMAL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
74 ygtl_t yg_texture_lumps = YGTL_NORMAL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
75 al_llist_t *ldtdef = NULL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
76 al_llist_t *ldtgroup = NULL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
77 al_llist_t *stdef = NULL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
78 al_llist_t *thingdef = NULL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
79 al_llist_t *thinggroup = NULL; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
80 Wad_name sky_flat; |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
81 |
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
82 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
83 Wad_res wad_res(&cfg.MasterDir); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
84 YadexConfig cfg; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
85 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
86 void InitializeConfig() |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
87 { |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
88 memset(&cfg, 0, sizeof(cfg)); |
82
154714f3ab2e
Move declarations around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
89 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
90 cfg.install_dir = NULL, // Where Yadex is installed |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
91 cfg.logfile = NULL, // Filepointer to the error log |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
92 cfg.registered = false, // Registered or shareware game? |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
93 cfg.screen_lines = 24, // Lines that our TTY can display |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
94 cfg.remind_to_build_nodes = false, // Remind user to build nodes |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
95 cfg.config_file = NULL; |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
96 cfg.debug = false; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
97 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
98 // Set from command line and/or config file |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
99 cfg.autoscroll = false; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
100 cfg.autoscroll_amp = 10; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
101 cfg.autoscroll_edge = 30; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
102 cfg.copy_linedef_reuse_sidedefs = false; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
103 cfg.cpu_big_endian = false; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
104 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
105 cfg.def.ceiling_height = 128; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
106 strcpy(cfg.def.ceiling_texture, "CEIL3_5"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
107 cfg.def.floor_height = 0; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
108 strcpy(cfg.def.floor_texture, "FLOOR4_8"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
109 cfg.def.light_level = 144; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
110 strcpy(cfg.def.lower_texture, "STARTAN3"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
111 strcpy(cfg.def.middle_texture, "STARTAN3"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
112 strcpy(cfg.def.upper_texture, "STARTAN3"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
113 cfg.def.thing = 3004; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
114 cfg.double_click_timeout = 200; |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
115 cfg.expert = false; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
116 cfg.Game = NULL; |
0 | 117 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
118 cfg.patchwads = NULL; |
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
119 cfg.quiet = false; |
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
120 cfg.quieter = false; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
121 cfg.scroll_less = 10; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
122 cfg.scroll_more = 90; |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
123 cfg.autoselect0 = false; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
124 cfg.show_help = false; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
125 cfg.sprite_scale = 100; |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
126 cfg.swap_buttons = false; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
127 cfg.verbose = 0; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
128 cfg.welcome_message = 1; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
129 cfg.bench = NULL; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
130 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
131 memset(cfg.iwadnames, 0, sizeof(cfg.iwadnames)); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
132 cfg.MainWad = NULL; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
133 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
134 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
135 cfg.grid_pixels_min = 10; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
136 cfg.GridMin = 2; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
137 cfg.GridMax = 128; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
138 cfg.idle_sleep_ms = 50; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
139 cfg.InfoShown = true; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
140 cfg.zoom_default = 0; // 0 means fit |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
141 cfg.zoom_step = 0; // 0 means sqrt(2) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
142 cfg.digit_zoom_base = 100; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
143 cfg.digit_zoom_step = 0; // 0 means sqrt(2) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
144 |
0 | 145 #ifdef AYM_MOUSE_HACKS |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
146 cfg.MouseMickeysH = 5; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
147 cfg.MouseMickeysV = 5; |
0 | 148 #endif |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
149 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
150 cfg.insert_vertex_split_linedef = YC_ASK_ONCE; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
151 cfg.insert_vertex_merge_vertices = YC_ASK_ONCE; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
152 cfg.blindly_swap_sidedefs = false; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
153 } |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
154 |
0 | 155 |
156 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
157 * Prototypes of private functions |
0 | 158 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
159 static void MainLoop(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
160 static void add_base_colours(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
161 static const Wad_file *wad_by_name(const char *pathname); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
162 static bool wad_already_loaded(const char *pathname); |
0 | 163 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
164 typedef struct |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
165 { |
12
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
166 const char *game, *wadname; |
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
167 } GameInfo; |
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
168 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
169 GameInfo gameList[IWAD_LAST] = { |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
170 {"doom", "doom.wad"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
171 {"doom2", "doom2.wad"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
172 {"heretic", "heretic.wad"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
173 {"hexen", "hexen.wad"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
174 {"strife", "strife1.wad"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
175 {"doom02", "Doom alpha 0.2 IWAD"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
176 {"doom04", "Doom alpha 0.4 IWAD"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
177 {"doom05", "Doom alpha 0.5 IWAD"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
178 {"doompr", "Doom Press Release IWAD"}, |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
179 {"strife10", "strife1.wad"} |
12
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
180 }; |
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
181 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
182 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
183 /* |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
184 * parse_environment_vars |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
185 * Check certain environment variables. |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
186 */ |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
187 static void parse_environment_vars(void) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
188 { |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
189 char *value; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
190 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
191 if ((value = getenv("YADEX_GAME")) != NULL) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
192 cfg.Game = value; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
193 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
194 if ((value = getenv("LINES")) != NULL) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
195 cfg.screen_lines = atoi(value); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
196 else |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
197 cfg.screen_lines = 0; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
198 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
199 if (cfg.screen_lines == 0) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
200 cfg.screen_lines = 24; |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
201 } |
12
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
202 |
0 | 203 |
204 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
205 * main |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
206 * Guess what. |
0 | 207 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
208 int main(int argc, char *argv[]) |
0 | 209 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
210 int r; |
0 | 211 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
212 InitializeConfig(); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
213 parse_environment_vars(); |
0 | 214 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
215 if (argc == 2 && strcmp(argv[1], "--help") == 0) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
216 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
217 print_usage(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
218 exit(0); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
219 } |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
220 if (argc == 2 && strcmp(argv[1], "--version") == 0) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
221 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
222 puts(what()); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
223 puts(config_file_magic); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
224 puts(ygd_file_magic); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
225 exit(0); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
226 } |
0 | 227 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
228 // Second a quick pass through the command line |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
229 // arguments to detect -?, -f and -help. |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
230 r = parse_command_line_options(argc - 1, argv + 1, 1); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
231 if (r) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
232 goto syntax_error; |
0 | 233 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
234 if (cfg.show_help) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
235 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
236 print_usage(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
237 exit(1); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
238 } |
0 | 239 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
240 printf("%s\n", what()); |
0 | 241 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
242 // Where am I installed ? (the config file might be there) |
0 | 243 #if defined Y_DOS |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
244 install_dir = spec_path(argv[0]); |
0 | 245 #endif |
246 | |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
247 // The config file provides some values. |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
248 if (cfg.config_file != NULL) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
249 r = parse_config_file_user(cfg.config_file); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
250 else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
251 r = parse_config_file_default(); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
252 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
253 if (r == 0) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
254 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
255 // Environment variables can override them. |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
256 parse_environment_vars(); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
257 r = parse_command_line_options(argc - 1, argv + 1, 2); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
258 } |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
259 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
260 if (r != 0) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
261 { |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
262 syntax_error: |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
263 fprintf(stderr, "Try \"yadex --help\" or \"man yadex\".\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
264 exit(1); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
265 } |
0 | 266 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
267 if (cfg.Game != NULL) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
268 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
269 int n; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
270 for (n = 0; n < IWAD_LAST; n++) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
271 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
272 GameInfo *info = &gameList[n]; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
273 if (strcmp(cfg.Game, info->game) == 0) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
274 { |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
275 if (cfg.iwadnames[n] == NULL) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
276 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
277 err("You have to tell me where %s is.", info->wadname); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
278 fprintf(stderr, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
279 "Use \"-i%d <file>\" or put \"iwad%d=<file>\" in yadex.cfg\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
280 n + 1, n + 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
281 exit(1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
282 } |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
283 cfg.MainWad = cfg.iwadnames[n]; |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
284 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
285 } |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
286 } |
12
cc5de2dcf008
Clean up the option checking code slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
287 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
288 if (cfg.MainWad == NULL) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
289 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
290 int n; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
291 if (cfg.Game == NULL) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
292 err("You didn't say for which game you want to edit."); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
293 else |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
294 err("Unknown game \"%s\"", cfg.Game); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
295 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
296 fprintf(stderr, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
297 "Use \"-g <game>\" on the command line or put \"game=<game>\" in yadex.cfg\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
298 "where <game> is one of: "); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
299 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
300 for (n = 0; n < IWAD_LAST; n++) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
301 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
302 fprintf(stderr, "%s\"%s\"", n > 0 ? ", " : "", gameList[n].game); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
303 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
304 fprintf(stderr, ".\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
305 exit(1); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
306 } |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
307 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
308 if (cfg.debug) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
309 { |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
310 cfg.logfile = fopen(yadex_log_filename, "a"); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
311 if (cfg.logfile == NULL) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
312 { |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
313 warn("Can't open log file \"%s\" (%s)", yadex_log_filename, |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
314 strerror(errno)); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
315 } |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
316 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
317 LogMessage(": Main IWAD = '%s'\n", cfg.MainWad); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
318 LogMessage(": Welcome to Yadex!\n"); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
319 } |
0 | 320 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
321 if (cfg.quieter) |
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
322 cfg.quiet = true; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
323 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
324 // Sanity checks (useful when porting). |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
325 check_types(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
326 check_charset(); |
0 | 327 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
328 // Misc. things done only once. |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
329 cfg.cpu_big_endian = native_endianness(); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
330 add_base_colours(); |
0 | 331 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
332 // Load game definitions (*.ygd). |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
333 InitGameDefs(); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
334 LoadGameDefs(cfg.Game); |
0 | 335 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
336 // Load the iwad and the pwads. |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
337 if (OpenMainWad(cfg.MainWad)) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
338 fatal_error("If you don't give me an iwad, I'll quit. I'm serious."); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
339 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
340 if (cfg.patchwads) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
341 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
342 const char *const *pwad_name; |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
343 for (pwad_name = cfg.patchwads; *pwad_name; pwad_name++) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
344 OpenPatchWad(*pwad_name); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
345 } |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
346 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
347 /* sanity check */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
348 CloseUnusedWadFiles(); |
0 | 349 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
350 // BRANCH 1 : benchmarking (-b) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
351 if (cfg.bench != NULL) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
352 { |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
353 benchmark(cfg.bench); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
354 return 0; // Exit successfully |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
355 } |
0 | 356 |
357 // BRANCH 2 : normal use ("yadex:" prompt) | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
358 else |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
359 { |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
360 if (cfg.welcome_message) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
361 print_welcome(stdout); |
0 | 362 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
363 if (strcmp(cfg.Game, "hexen") == 0) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
364 printf |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
365 ("WARNING: Hexen mode is experimental. Don't expect to be able to do any\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
366 "real Hexen editing with it. You can edit levels but you can't save them.\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
367 "And there might be other bugs... BE CAREFUL !\n\n"); |
0 | 368 |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
369 if (strcmp(cfg.Game, "strife") == 0) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
370 printf |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
371 ("WARNING: Strife mode is experimental. Many thing types, linedef types,\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
372 "etc. are missing or wrong. And be careful, there might be bugs.\n\n"); |
0 | 373 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
374 /* all systems go! */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
375 MainLoop(); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
376 } |
0 | 377 |
378 /* that's all, folks! */ | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
379 CloseWadFiles(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
380 FreeGameDefs(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
381 LogMessage(": The end!\n\n\n"); |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
382 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
383 if (cfg.logfile != NULL) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
384 fclose(cfg.logfile); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
385 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
386 if (cfg.remind_to_build_nodes) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
387 printf("\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
388 "** You have made changes to one or more wads. Don't forget to pass\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
389 "** them through a nodes builder (E.G. BSP) before running them.\n" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
390 "** Like this: \"ybsp foo.wad -o tmp.wad; doom -file tmp.wad\"\n\n"); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
391 return 0; |
0 | 392 } |
393 | |
394 | |
395 /* | |
396 play a fascinating tune | |
397 */ | |
398 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
399 void Beep() |
0 | 400 { |
401 } | |
402 | |
403 | |
404 | |
405 /* | |
406 play a sound | |
407 */ | |
408 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
409 void PlaySound(int freq, int msec) |
0 | 410 { |
411 #if defined Y_DOS | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
412 if (!Quiet) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
413 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
414 sound(freq); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
415 delay(msec); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
416 nosound(); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
417 } |
0 | 418 #elif defined Y_UNIX |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
419 freq = msec; // To prevent a warning about unused variables |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
420 return; |
0 | 421 #endif |
422 } | |
423 | |
424 | |
425 | |
426 /* | |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
427 * print_error_message |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
428 * Print an error message to stderr. |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
429 */ |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
430 static void print_error_message(const char *fmt, va_list args) |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
431 { |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
432 fflush(stdout); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
433 fputs("Error: ", stderr); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
434 vfprintf(stderr, fmt, args); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
435 fputc('\n', stderr); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
436 fflush(stderr); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
437 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
438 if (cfg.debug && cfg.logfile != NULL) |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
439 { |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
440 fputs("Error: ", cfg.logfile); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
441 vfprintf(cfg.logfile, fmt, args); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
442 fputc('\n', cfg.logfile); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
443 fflush(cfg.logfile); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
444 } |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
445 } |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
446 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
447 |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
448 /* |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
449 * fatal_error |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
450 * Print an error message and terminate the program with code 2. |
0 | 451 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
452 void fatal_error(const char *fmt, ...) |
0 | 453 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
454 va_list args; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
455 va_start(args, fmt); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
456 print_error_message(fmt, args); |
0 | 457 |
458 // ... on the other hand, with X, we don't have to | |
459 // call TermGfx() before printing so we do it last so | |
460 // that a segfault occuring in TermGfx() does not | |
461 // prevent us from seeing the stderr message. | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
462 TermGfx(); // Don't need to sleep (1) either. |
0 | 463 |
464 // Clean up things and free swap space | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
465 ForgetLevelData(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
466 ForgetWTextureNames(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
467 ForgetFTextureNames(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
468 CloseWadFiles(); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
469 exit(2); |
0 | 470 } |
471 | |
472 | |
473 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
474 * err |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
475 * Print an error message but do not terminate the program. |
0 | 476 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
477 void err(const char *fmt, ...) |
0 | 478 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
479 va_list args; |
0 | 480 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
481 va_start(args, fmt); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
482 print_error_message(fmt, args); |
0 | 483 } |
484 | |
485 | |
486 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
487 * nf_bug |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
488 * Report about a non-fatal bug to stderr. The message |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
489 * should not expand to more than 80 characters. |
0 | 490 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
491 void nf_bug(const char *fmt, ...) |
0 | 492 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
493 static bool first_time = 1; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
494 static int repeats = 0; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
495 static char msg_prev[81]; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
496 char msg[81]; |
0 | 497 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
498 va_list args; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
499 va_start(args, fmt); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
500 y_vsnprintf(msg, sizeof msg, fmt, args); |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
501 if (first_time || strncmp(msg, msg_prev, sizeof msg)) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
502 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
503 fflush(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
504 if (repeats) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
505 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
506 fprintf(stderr, "Bug: Previous message repeated %d times\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
507 repeats); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
508 repeats = 0; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
509 } |
0 | 510 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
511 fprintf(stderr, "Bug: %s\n", msg); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
512 fflush(stderr); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
513 if (first_time) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
514 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
515 fputs("REPORT ALL \"Bug:\" MESSAGES TO THE MAINTAINER !\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
516 stderr); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
517 first_time = 0; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
518 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
519 strncpy(msg_prev, msg, sizeof msg_prev); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
520 } |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
521 else |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
522 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
523 repeats++; // Same message as above |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
524 if (repeats == 10) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
525 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
526 fflush(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
527 fprintf(stderr, "Bug: Previous message repeated %d times\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
528 repeats); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
529 fflush(stderr); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
530 repeats = 0; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
531 } |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
532 } |
0 | 533 } |
534 | |
535 | |
536 /* | |
537 write a message in the log file | |
538 */ | |
539 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
540 void LogMessage(const char *logstr, ...) |
0 | 541 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
542 va_list args; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
543 time_t tval; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
544 char *tstr; |
0 | 545 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
546 if (cfg.debug && cfg.logfile != NULL) |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
547 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
548 va_start(args, logstr); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
549 /* if the message begins with ":", output the current date & time first */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
550 if (logstr[0] == ':') |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
551 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
552 time(&tval); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
553 tstr = ctime(&tval); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
554 tstr[strlen(tstr) - 1] = '\0'; |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
555 fprintf(cfg.logfile, "%s", tstr); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
556 } |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
557 vfprintf(cfg.logfile, logstr, args); |
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
558 fflush(cfg.logfile); /* AYM 19971031 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
559 } |
0 | 560 } |
561 | |
562 | |
76
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
563 void PrintHelp() |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
564 { |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
565 printf("? | h | help --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
566 " display this text\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
567 printf("b[uild] <WadFile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
568 " build a new iwad\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
569 printf("c[reate] <levelname> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
570 " create and edit a new (empty) level\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
571 printf("d[ump] <DirEntry> [outfile] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
572 " dump a directory entry in hex\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
573 printf("e[dit] <levelname> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
574 " edit a game level saving results to\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
575 printf |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
576 (" a patch wad file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
577 printf("g[roup] <WadFile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
578 " group all patch wads in a file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
579 printf("i[nsert] <RawFile> <DirEntry> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
580 " insert a raw file in a patch wad file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
581 printf("l[ist] <WadFile> [outfile] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
582 " list the directory of a wadfile\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
583 printf("m[aster] [outfile] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
584 " list the master directory\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
585 printf("make_gimp_palette <outfile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
586 " generate a gimp palette file from\n" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
587 " " |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
588 " entry 0 of lump PLAYPAL.\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
589 printf("make_palette_ppm <outfile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
590 " generate a palette image from\n" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
591 " " |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
592 " entry 0 of lump PLAYPAL.\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
593 printf("q[uit] --" " quit\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
594 printf("r[ead] <WadFile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
595 " read a new wad patch file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
596 printf("s[ave] <DirEntry> <WadFile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
597 " save one object to a separate file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
598 printf("set --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
599 " list all options and their values\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
600 printf("v[iew] [<spritename>] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
601 " display the sprites\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
602 printf("viewflat [<flatname>] --" " flat viewer\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
603 printf("viewpal --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
604 " palette viewer\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
605 printf("viewpat [<patchname>] --" " patch viewer\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
606 printf("viewtex [<texname>] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
607 " texture viewer\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
608 printf("w[ads] --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
609 " display the open wads\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
610 printf("x[tract] <DirEntry> <RawFile> --" |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
611 " save (extract) one object to a raw file\n"); |
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
612 } |
0 | 613 |
614 /* | |
615 the main program menu loop | |
616 */ | |
617 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
618 static void MainLoop() |
0 | 619 { |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
620 #ifdef Y_READLINE |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
621 char *input = NULL; |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
622 #else |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
623 char input[120]; |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
624 #endif |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
625 char *com, *out; |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
626 FILE *file, *raw; |
0 | 627 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
628 for (;;) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
629 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
630 /* get the input */ |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
631 #ifdef Y_READLINE |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
632 input = readline("yadex: "); |
38
e5cd0f139fc1
Adding to readline history should be done before any string manipulations.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
633 add_history(input); |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
634 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
635 printf("yadex: "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
636 if (!fgets(input, sizeof input, stdin)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
637 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
638 puts("q"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
639 break; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
640 } |
0 | 641 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
642 /* Strip the trailing '\n' */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
643 if (strlen(input) > 0 && input[strlen(input) - 1] == '\n') |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
644 input[strlen(input) - 1] = '\0'; |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
645 #endif |
0 | 646 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
647 /* eat the white space and get the first command word */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
648 com = strtok(input, " "); |
0 | 649 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
650 /* user just hit return */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
651 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
652 printf("Please enter a command or ? for help.\n"); |
0 | 653 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
654 /* user inputting for help */ |
77 | 655 else if (!strcmp(com, "?") || !strcmp(com, "h") || !strcmp(com, "help")) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
656 { |
76
042b44809e6e
Move help printing to separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
657 PrintHelp(); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
658 } |
0 | 659 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
660 /* user asked for list of open wad files */ |
77 | 661 else if (!strcmp(com, "wads") || !strcmp(com, "w")) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
662 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
663 const Wad_file *wf; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
664 wad_list.rewind(); |
77 | 665 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
666 if (wad_list.get(wf)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
667 printf("%-40s Iwad\n", wf->pathname()); |
77 | 668 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
669 while (wad_list.get(wf)) |
77 | 670 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
671 printf("%-40s Pwad (%.*s)\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
672 wf->pathname(), (int) WAD_NAME, wf->what()); |
77 | 673 } |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
674 } |
0 | 675 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
676 /* user asked to quit */ |
77 | 677 else if (!strcmp(com, "quit") || !strcmp(com, "q")) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
678 { |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
679 if (!cfg.registered) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
680 printf("Remember to register your copy of the game !\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
681 break; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
682 } |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
683 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
684 /* user asked to edit a level */ |
77 | 685 else if (!strcmp(com, "edit") || !strcmp(com, "e") || |
686 !strcmp(com, "create") || !strcmp(com, "c")) | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
687 { |
77 | 688 const bool newlevel = (com[0] == 'c'); |
689 char *level_name = NULL; | |
690 | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
691 com = strtok(NULL, " "); |
77 | 692 if (com == NULL) |
693 { | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
694 if (!newlevel) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
695 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
696 printf("Which level ?\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
697 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
698 } |
77 | 699 } |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
700 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
701 { |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
702 MDirPtr entry = FindMasterDir(cfg.MasterDir, com); |
78
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
703 if (entry != NULL) |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
704 { |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
705 level_name = strdup(entry->dir.name); |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
706 } |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
707 else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
708 { |
77 | 709 printf("Level '%s' not found.", com); |
78
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
710 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
711 // Hint absent-minded users |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
712 if ((tolower(*com) == 'e' && yg_level_name == YGLN_MAP01) || |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
713 (tolower(*com) == 'm' && yg_level_name == YGLN_E1M1)) |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
714 printf(" You are in %s mode.", cfg.Game); |
77 | 715 else |
78
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
716 |
83
002bc70a3982
More cleanups. Mostly variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
717 if (tolower(*com) == 'e' && com[1] > '1' && !cfg.registered) |
78
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
718 printf(" You have the shareware IWAD."); |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
719 |
626678d4ecf3
Changes in e6175d0a667b were buggy, find_level logic replacement now fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
720 printf("\n"); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
721 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
722 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
723 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
724 EditLevel(level_name, newlevel); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
725 } |
0 | 726 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
727 /* user asked to build a new main wad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
728 else if (strcmp(com, "build") == 0 || strcmp(com, "b") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
729 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
730 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
731 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
732 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
733 printf("Wad file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
734 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
735 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
736 if (wad_already_loaded(com)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
737 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
738 printf("%s: in use, close it first\n", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
739 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
740 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
741 BuildNewMainWad(com, 0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
742 } |
0 | 743 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
744 /* user asked to build a compound patch wad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
745 else if (strcmp(com, "group") == 0 || strcmp(com, "g") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
746 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
747 wad_list.rewind(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
748 const Wad_file *wf; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
749 if (!wad_list.get(wf) || !wad_list.get(wf)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
750 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
751 printf("You need at least two open wad files " |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
752 "if you want to group them.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
753 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
754 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
755 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
756 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
757 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
758 printf("Wad file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
759 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
760 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
761 if (wad_already_loaded(com)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
762 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
763 printf("%s: in use, close it first\n", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
764 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
765 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
766 BuildNewMainWad(com, 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
767 } |
0 | 768 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
769 /* user ask for a listing of a wad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
770 else if (strcmp(com, "list") == 0 || strcmp(com, "l") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
771 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
772 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
773 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
774 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
775 printf("Wad file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
776 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
777 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
778 const Wad_file *wf = wad_by_name(com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
779 if (wf == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
780 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
781 printf("%s: not open\n", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
782 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
783 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
784 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
785 if (out) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
786 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
787 printf("Outputting directory of \"%s\" to \"%s\".\n", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
788 wf->pathname(), out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
789 if ((file = fopen(out, "w")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
790 fatal_error("error opening output file \"%s\"", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
791 fprintf(file, "%s\n", what()); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
792 ListFileDirectory(file, wf); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
793 fprintf(file, "\nEnd of file.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
794 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
795 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
796 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
797 ListFileDirectory(stdout, wf); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
798 } |
0 | 799 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
800 /* user asked for the list of the master directory */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
801 else if (strcmp(com, "master") == 0 || strcmp(com, "m") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
802 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
803 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
804 if (out) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
805 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
806 printf("Outputting master directory to \"%s\".\n", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
807 if ((file = fopen(out, "w")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
808 fatal_error("error opening output file \"%s\"", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
809 fprintf(file, "%s\n", what()); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
810 ListMasterDirectory(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
811 fprintf(file, "\nEnd of file.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
812 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
813 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
814 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
815 ListMasterDirectory(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
816 } |
0 | 817 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
818 // make_gimp_palette |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
819 else if (strcmp(com, "make_gimp_palette") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
820 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
821 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
822 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
823 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
824 printf("Output file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
825 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
826 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
827 make_gimp_palette(0, out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
828 } |
0 | 829 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
830 // make_palette_ppm |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
831 else if (strcmp(com, "make_palette_ppm") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
832 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
833 out = strtok(NULL, ""); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
834 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
835 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
836 printf("Output file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
837 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
838 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
839 make_palette_ppm(0, out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
840 } |
0 | 841 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
842 // make_palette_ppm |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
843 else if (strcmp(com, "mp2") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
844 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
845 out = strtok(NULL, ""); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
846 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
847 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
848 printf("Output file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
849 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
850 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
851 make_palette_ppm_2(0, out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
852 } |
0 | 853 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
854 /* user asked to list all options and their values */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
855 else if (strcmp(com, "set") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
856 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
857 dump_parameters(stdout); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
858 } |
0 | 859 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
860 /* user asked to read a new patch wad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
861 else if (strcmp(com, "read") == 0 || strcmp(com, "r") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
862 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
863 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
864 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
865 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
866 printf("Wad file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
867 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
868 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
869 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
870 if (out) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
871 *out = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
872 out = (char *) GetMemory(strlen(com) + 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
873 strcpy(out, com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
874 OpenPatchWad(out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
875 CloseUnusedWadFiles(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
876 } |
0 | 877 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
878 /* user asked to dump the contents of a wad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
879 else if (strcmp(com, "dump") == 0 || strcmp(com, "d") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
880 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
881 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
882 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
883 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
884 printf("Object name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
885 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
886 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
887 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
888 if (out) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
889 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
890 printf("Outputting directory entry data to \"%s\".\n", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
891 if ((file = fopen(out, "w")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
892 fatal_error("error opening output file \"%s\"", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
893 fprintf(file, "%s\n", what()); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
894 DumpDirectoryEntry(file, com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
895 fprintf(file, "\nEnd of file.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
896 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
897 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
898 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
899 DumpDirectoryEntry(stdout, com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
900 } |
0 | 901 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
902 // "v"/"view" - view the sprites |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
903 else if (strcmp(com, "view") == 0 || strcmp(com, "v") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
904 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
905 if (InitGfx()) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
906 goto v_end; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
907 init_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
908 do |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
909 get_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
910 while (is.key != YE_EXPOSE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
911 force_window_not_pixmap(); // FIXME quick hack |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
912 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
913 Lump_list list; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
914 wad_res.sprites.list(list); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
915 char buf[WAD_PIC_NAME + 1]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
916 const char *sprite = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
917 *buf = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
918 if (sprite != 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
919 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
920 strncat(buf, sprite, sizeof buf - 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
921 for (char *p = buf; *p != '\0'; p++) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
922 *p = toupper(*p); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
923 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
924 InputNameFromListWithFunc(-1, -1, "Sprite viewer", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
925 list.size(), list.data(), 10, buf, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
926 320, 200, display_pic, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
927 HOOK_DISP_SIZE | HOOK_SPRITE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
928 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
929 TermGfx(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
930 v_end:; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
931 } |
0 | 932 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
933 // "viewflat" - view the flats |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
934 else if (strcmp(com, "viewflat") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
935 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
936 if (InitGfx()) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
937 goto viewflat_end; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
938 init_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
939 do |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
940 get_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
941 while (is.key != YE_EXPOSE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
942 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
943 force_window_not_pixmap(); // FIXME quick hack |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
944 char buf[WAD_FLAT_NAME + 1]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
945 *buf = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
946 if (com != 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
947 strncat(buf, com, sizeof buf - 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
948 ReadFTextureNames(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
949 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
950 char **flat_names = |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
951 (char **) GetMemory(NumFTexture * sizeof *flat_names); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
952 for (size_t n = 0; n < NumFTexture; n++) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
953 flat_names[n] = flat_list[n].name; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
954 ChooseFloorTexture(-1, -1, "Flat viewer", |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
955 NumFTexture, flat_names, buf); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
956 FreeMemory(flat_names); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
957 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
958 ForgetFTextureNames(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
959 TermGfx(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
960 viewflat_end:; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
961 } |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
962 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
963 // "viewpal" - view the palette (PLAYPAL and COLORMAP) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
964 else if (strcmp(com, "viewpal") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
965 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
966 if (InitGfx()) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
967 goto viewpal_end; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
968 init_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
969 do |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
970 get_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
971 while (is.key != YE_EXPOSE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
972 force_window_not_pixmap(); // FIXME quick hack |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
973 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
974 Palette_viewer pv; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
975 pv.run(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
976 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
977 TermGfx(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
978 viewpal_end:; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
979 } |
0 | 980 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
981 // "viewpat" - view the patches |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
982 else if (strcmp(com, "viewpat") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
983 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
984 if (InitGfx()) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
985 goto viewpat_end; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
986 init_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
987 do |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
988 get_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
989 while (is.key != YE_EXPOSE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
990 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
991 force_window_not_pixmap(); // FIXME quick hack |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
992 patch_dir.refresh(cfg.MasterDir); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
993 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
994 char buf[WAD_NAME + 1]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
995 *buf = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
996 if (com != 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
997 strncat(buf, com, sizeof buf - 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
998 Patch_list pl; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
999 patch_dir.list(pl); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1000 InputNameFromListWithFunc(-1, -1, "Patch viewer", pl.size(), |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1001 pl.data(), 10, buf, 256, 256, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1002 display_pic, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1003 HOOK_DISP_SIZE | HOOK_PATCH); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1004 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1005 TermGfx(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1006 viewpat_end:; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1007 } |
0 | 1008 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1009 // "viewtex" - view the textures |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1010 else if (strcmp(com, "viewtex") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1011 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1012 if (InitGfx()) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1013 goto viewtex_end; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1014 init_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1015 do |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1016 get_input_status(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1017 while (is.key != YE_EXPOSE); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1018 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1019 force_window_not_pixmap(); // FIXME quick hack |
80
2f1ecc1c5f72
Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
1020 patch_dir.refresh(cfg.MasterDir); |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1021 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1022 char buf[WAD_TEX_NAME + 1]; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1023 *buf = '\0'; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1024 if (com != 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1025 strncat(buf, com, sizeof buf - 1); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1026 ReadWTextureNames(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1027 ChooseWallTexture(-1, -1, "Texture viewer", NumWTexture, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1028 WTexture, buf); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1029 ForgetWTextureNames(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1030 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1031 TermGfx(); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1032 viewtex_end:; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1033 } |
0 | 1034 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1035 /* user asked to save an object to a separate pwad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1036 else if (strcmp(com, "save") == 0 || strcmp(com, "s") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1037 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1038 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1039 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1040 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1041 printf("Object name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1042 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1043 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1044 if (strlen(com) > WAD_NAME || strchr(com, '.') != NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1045 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1046 printf("Invalid object name.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1047 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1048 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1049 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1050 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1051 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1052 printf("Wad file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1053 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1054 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1055 if (wad_already_loaded(com)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1056 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1057 printf("%s: in use, close it first\n", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1058 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1059 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1060 printf("Saving directory entry data to \"%s\".\n", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1061 if ((file = fopen(out, "wb")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1062 fatal_error("error opening output file \"%s\"", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1063 SaveDirectoryEntry(file, com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1064 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1065 } |
0 | 1066 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1067 /* user asked to encapsulate a raw file in a pwad file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1068 else if (strcmp(com, "insert") == 0 || strcmp(com, "i") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1069 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1070 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1071 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1072 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1073 printf("Raw file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1074 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1075 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1076 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1077 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1078 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1079 printf("Object name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1080 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1081 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1082 if (strlen(out) > WAD_NAME || strchr(out, '.') != NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1083 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1084 printf("Invalid object name.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1085 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1086 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1087 if ((raw = fopen(com, "rb")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1088 fatal_error("error opening input file \"%s\"", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1089 /* kluge */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1090 strcpy(input, out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1091 strcat(input, ".wad"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1092 if (wad_already_loaded(input)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1093 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1094 printf("%s: in use, close it first\n", input); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1095 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1096 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1097 printf("Including new object %s in \"%s\".\n", out, input); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1098 if ((file = fopen(input, "wb")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1099 fatal_error("error opening output file \"%s\"", input); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1100 SaveEntryFromRawFile(file, raw, out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1101 fclose(raw); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1102 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1103 } |
0 | 1104 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1105 /* user asked to extract an object to a raw binary file */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1106 else if (strcmp(com, "xtract") == 0 |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1107 || strcmp(com, "extract") == 0 || strcmp(com, "x") == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1108 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1109 com = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1110 if (com == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1111 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1112 printf("Object name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1113 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1114 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1115 if (strlen(com) > WAD_NAME || strchr(com, '.') != NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1116 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1117 printf("Invalid object name.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1118 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1119 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1120 out = strtok(NULL, " "); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1121 if (out == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1122 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1123 printf("Raw file name argument missing.\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1124 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1125 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1126 if (wad_already_loaded(com)) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1127 { |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1128 printf("%s: in use, close it first\n", com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1129 printf |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1130 ("Besides do you really want to overwrite a wad file with" |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1131 " raw data ?\n"); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1132 continue; |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1133 } |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1134 printf("Saving directory entry data to \"%s\".\n", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1135 if ((file = fopen(out, "wb")) == NULL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1136 fatal_error("error opening output file \"%s\"", out); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1137 SaveEntryToRawFile(file, com); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1138 fclose(file); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1139 } |
0 | 1140 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1141 /* unknown command */ |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1142 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1143 printf("Unknown command \"%s\"!\n", com); |
37
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
1144 |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
1145 #ifdef Y_READLINE |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
1146 free(input); |
5f366c1ed459
Add support for GNU readline library for easier editing of the commands.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
1147 #endif |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1148 } |
0 | 1149 } |
1150 | |
1151 | |
1152 /* | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1153 * add_base_colours |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1154 * Add the NCOLOURS base colours to the list of |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1155 * application colours. |
0 | 1156 */ |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1157 static void add_base_colours() |
0 | 1158 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1159 for (size_t n = 0; n < NCOLOURS; n++) |
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1160 { |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1161 rgb_c c; |
0 | 1162 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1163 // The first 16 are the standard IRGB VGA colours. |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1164 // FIXME they're to be removed and replaced by |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1165 // "logical" colours. |
0 | 1166 #ifdef WHITE_BACKGROUND |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1167 if (n == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1168 irgb2rgb(15, &c); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1169 else if (n == 15) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1170 irgb2rgb(0, &c); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1171 else |
0 | 1172 #endif |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1173 if (n < 16) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1174 irgb2rgb(n, &c); |
0 | 1175 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1176 // Then there are the colours used to draw the |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1177 // windows and the map. The colours used to draw |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1178 // the things are parametrized in the .ygd ; they |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1179 // are added by load_game(). |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1180 // FIXME they should not be hard-coded, of course ! |
0 | 1181 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1182 /* WINBG* is for window backgrounds. Use the _HL variant is |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1183 for highlighted parts of windows (E.G. the current line in |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1184 a menu). _LIGHT and _DARK are for window borders and |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1185 grooves. There is no _HL flavour of these because I didn't |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1186 feel the need. */ |
0 | 1187 #ifdef WHITE_BACKGROUND |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1188 else if (n == WINBG) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1189 c.set(0xe2, 0xdc, 0xd6); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1190 else if (n == WINBG_LIGHT) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1191 c.set(0xee, 0xe8, 0xe2); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1192 else if (n == WINBG_DARK) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1193 c.set(0xc3, 0xbe, 0xb9); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1194 else if (n == WINBG_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1195 c.set(0xf4, 0xee, 0xe7); |
0 | 1196 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1197 else if (n == WINBG) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1198 c.set(0x2a, 0x24, 0x18); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1199 else if (n == WINBG_LIGHT) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1200 c.set(0x48, 0x42, 0x3c); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1201 else if (n == WINBG_DARK) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1202 c.set(0x20, 0x1b, 0x12); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1203 else if (n == WINBG_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1204 c.set(0x58, 0x50, 0x48); |
0 | 1205 #endif |
1206 | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1207 /* WINFG* is for regular text. _DIM is for greyed out text |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1208 (for disabled options or text that is not applicable). */ |
0 | 1209 #ifdef WHITE_BACKGROUND |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1210 else if (n == WINFG) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1211 c.set(0x60, 0x60, 0x60); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1212 else if (n == WINFG_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1213 c.set(0x30, 0x30, 0x30); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1214 else if (n == WINFG_DIM) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1215 c.set(0xB8, 0xB8, 0xB8); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1216 else if (n == WINFG_DIM_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1217 c.set(0x90, 0x90, 0x90); |
0 | 1218 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1219 else if (n == WINFG) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1220 c.set(0xa0, 0xa0, 0xa0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1221 else if (n == WINFG_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1222 c.set(0xd0, 0xd0, 0xd0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1223 else if (n == WINFG_DIM) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1224 c.set(0x48, 0x48, 0x48); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1225 else if (n == WINFG_DIM_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1226 c.set(0x70, 0x70, 0x70); |
0 | 1227 #endif |
1228 | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1229 /* WINLABEL is for text of lesser importance. For example, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1230 the brackets around key binding are displayed in WINLABEL, |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1231 while what's between them is displayed in WINFG. The |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1232 difference with WINFG is not very noticeable but it does |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1233 improve readability. The static text in the object info |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1234 windows should be displayed in WINLABEL. */ |
0 | 1235 #ifdef WHITE_BACKGROUND |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1236 else if (n == WINLABEL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1237 c.set(0x88, 0x88, 0x88); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1238 else if (n == WINLABEL_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1239 c.set(0x60, 0x60, 0x60); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1240 else if (n == WINLABEL_DIM) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1241 c.set(0xc8, 0xc8, 0xc8); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1242 else if (n == WINLABEL_DIM_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1243 c.set(0xb0, 0xb0, 0xb0); |
0 | 1244 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1245 else if (n == WINLABEL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1246 c.set(0x78, 0x78, 0x78); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1247 else if (n == WINLABEL_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1248 c.set(0xa0, 0xa0, 0xa0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1249 else if (n == WINLABEL_DIM) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1250 c.set(0x38, 0x38, 0x38); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1251 else if (n == WINLABEL_DIM_HL) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1252 c.set(0x50, 0x50, 0x50); |
0 | 1253 #endif |
1254 | |
1255 #ifdef WHITE_BACKGROUND | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1256 else if (n == GRID1) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1257 c.set(0x80, 0x80, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1258 else if (n == GRID2H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1259 c.set(0xf0, 0xf0, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1260 else if (n == GRID2V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1261 c.set(0xf0, 0xf0, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1262 else if (n == GRID3H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1263 c.set(0xd0, 0xd0, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1264 else if (n == GRID3V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1265 c.set(0xd0, 0xd0, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1266 else if (n == GRID4H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1267 c.set(0xb0, 0xb0, 0xff); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1268 else if (n == GRID4V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1269 c.set(0xb0, 0xb0, 0xff); |
0 | 1270 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1271 else if (n == GRID1) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1272 c.set(0, 0, 0xc0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1273 else if (n == GRID2H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1274 c.set(0, 0, 0x30); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1275 else if (n == GRID2V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1276 c.set(0, 0, 0x40); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1277 else if (n == GRID3H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1278 c.set(0, 0, 0x50); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1279 else if (n == GRID3V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1280 c.set(0, 0, 0x70); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1281 else if (n == GRID4H) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1282 c.set(0, 0, 0x80); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1283 else if (n == GRID4V) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1284 c.set(0, 0, 0xc0); |
0 | 1285 #endif |
1286 | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1287 else if (n == LINEDEF_NO) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1288 c.set(0x40, 0xd0, 0xf0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1289 else if (n == SECTOR_NO) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1290 c.set(0x40, 0xd0, 0xf0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1291 else if (n == THING_NO) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1292 c.set(0x40, 0xd0, 0xf0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1293 else if (n == VERTEX_NO) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1294 c.set(0x40, 0xd0, 0xf0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1295 else if (n == CLR_ERROR) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1296 c.set(0xff, 0, 0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1297 else if (n == THING_REM) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1298 c.set(0x40, 0x40, 0x40); |
0 | 1299 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1300 else if (n == SECTOR_TAG) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1301 c.set(0x00, 0xff, 0x00); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1302 else if (n == SECTOR_TAGTYPE) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1303 c.set(0x00, 0xe0, 0xe0); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1304 else if (n == SECTOR_TYPE) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1305 c.set(0x00, 0x80, 0xff); |
0 | 1306 |
1307 #ifdef WHITE_BACKGROUND | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1308 else if (n == WINTITLE) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1309 c.set(0xb0, 0x80, 0x00); |
0 | 1310 #else |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1311 else if (n == WINTITLE) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1312 c.set(0xff, 0xff, 0x00); |
0 | 1313 #endif |
1314 | |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1315 else |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1316 fatal_error("Wrong acn %d", n); |
0 | 1317 |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1318 acolour_t acn = add_app_colour(c); |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1319 if (acn != n) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1320 fatal_error("add_base_colours: got %d for %d\n", acn, n); |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1321 } |
0 | 1322 } |
1323 | |
1324 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1325 static const Wad_file *wad_by_name(const char *pathname) |
0 | 1326 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1327 const Wad_file *wf; |
0 | 1328 |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1329 for (wad_list.rewind(); wad_list.get(wf);) |
33
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1330 if (fncmp(pathname, wf->pathname()) == 0) |
a68786b9c74b
Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
1331 return wf; |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1332 return 0; |
0 | 1333 } |
1334 | |
1335 | |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1336 static bool wad_already_loaded(const char *pathname) |
0 | 1337 { |
25
8eaf72e2041b
Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1338 return wad_by_name(pathname) != 0; |
0 | 1339 } |