Rev 1 | Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 11 | ||
---|---|---|---|
Line 134... | Line 134... | ||
134 | default: |
134 | default: |
135 | break; |
135 | break; |
136 | } |
136 | } |
137 | } |
137 | } |
138 | 138 | ||
- | 139 | #ifdef __APPLE__ |
|
- | 140 | #include <pwd.h> // for struct passwd and getpwuid() |
|
- | 141 | #endif /* __APPLE__ */ |
|
139 | void Harness_Init(int* argc, char* argv[]) { |
142 | void Harness_Init(int* argc, char* argv[]) { |
140 | int result; |
143 | int result; |
141 | #ifndef DETHRACE_VERSION |
144 | #ifndef DETHRACE_VERSION |
142 | #define DETHRACE_VERSION "0.6.0-pmbaty" // Pierre-Marie Baty -- CMake fix |
145 | #define DETHRACE_VERSION "0.6.0-pmbaty" // Pierre-Marie Baty -- CMake fix |
143 | #endif // !DETHRACE_VERSION |
146 | #endif // !DETHRACE_VERSION |
Line 159... | Line 162... | ||
159 | harness_game_config.enable_diagnostics = 0; |
162 | harness_game_config.enable_diagnostics = 0; |
160 | // no volume multiplier |
163 | // no volume multiplier |
161 | harness_game_config.volume_multiplier = 1.0f; |
164 | harness_game_config.volume_multiplier = 1.0f; |
162 | // start window in windowed mode |
165 | // start window in windowed mode |
163 | harness_game_config.start_full_screen = 0; |
166 | harness_game_config.start_full_screen = 0; |
164 | // Emulate |
167 | // Emulate gore check |
165 | harness_game_config. |
168 | harness_game_config.gore_check = 0; |
- | 169 | // Enable Sound Options menu |
|
- | 170 | harness_game_config.sound_options = 1; // Pierre-Marie Baty -- invert option default value |
|
166 | // Skip binding socket to allow local network testing |
171 | // Skip binding socket to allow local network testing |
167 | harness_game_config.no_bind = 0; |
172 | harness_game_config.no_bind = 0; |
168 | 173 | ||
169 | // install signal handler by default |
174 | // install signal handler by default |
170 | harness_game_config.install_signalhandler = 1; |
175 | harness_game_config.install_signalhandler = 1; |
Line 179... | Line 184... | ||
179 | if (root_dir != NULL) { |
184 | if (root_dir != NULL) { |
180 | LOG_INFO("DETHRACE_ROOT_DIR is set to '%s'", root_dir); |
185 | LOG_INFO("DETHRACE_ROOT_DIR is set to '%s'", root_dir); |
181 | } else { |
186 | } else { |
182 | root_dir = OS_Dirname(argv[0]); |
187 | root_dir = OS_Dirname(argv[0]); |
183 | #ifdef __APPLE__ |
188 | #ifdef __APPLE__ |
184 |
|
189 | // Pierre-Marie Baty -- macOS .app fix |
- | 190 | // peek in ~/Library/Application Support/<DOTTED BUNDLE ID> |
|
- | 191 | // if the directory doesn't exist, create it and copy all the contents of root_dir in it |
|
- | 192 | // this is necessary to have a read/write copy of the game data to not invalidate the app bundle's code signature |
|
- | 193 | // disk space |
|
- | 194 | { |
|
- | 195 | extern int CFStringGetCString (void *theString, char *buffer, int bufferSize, uint32_t encoding); // avoid importing the whole Cocoa stuff |
|
- | 196 | extern void *CFBundleGetIdentifier (void *bundle); // avoid importing the whole Cocoa stuff |
|
- | 197 | extern void *CFBundleGetMainBundle (void); // avoid importing the whole Cocoa stuff |
|
- | 198 | static char data_path[1024] = ""; |
|
- | 199 | char bundle_id[256]; |
|
- | 200 | char *homedir = getenv ("HOME"); |
|
- | 201 | if (homedir == NULL) |
|
- | 202 | homedir = getpwuid (getuid ())->pw_dir; |
|
- | 203 | CFStringGetCString (CFBundleGetIdentifier (CFBundleGetMainBundle ()), bundle_id, sizeof (bundle_id), 0x08000100 /*kCFStringEncodingUTF8*/); |
|
- | 204 | sprintf (data_path, "%s/Library/Application Support/%s", homedir, bundle_id); |
|
- | 205 | if (access (data_path, 0) != 0) |
|
- | 206 | { |
|
- | 207 | mkdir (data_path, 0755); |
|
- | 208 | { |
|
- | 209 | char cp_cmd[2048]; |
|
- | 210 | sprintf (cp_cmd, "cp -LR \"%s/../Resources/DATA\" \"%s\"", root_dir, data_path); |
|
- | 211 | system (cp_cmd); |
|
- | 212 | } |
|
- | 213 | } |
|
- | 214 | root_dir = data_path; |
|
- | 215 | } |
|
185 | #endif /* __APPLE__ */ |
216 | #endif /* __APPLE__ */ |
186 | if (root_dir[0] == 0) |
217 | if (root_dir[0] == 0) |
187 | strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check |
218 | strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check |
188 | } |
219 | } |
189 | printf("Using root directory: %s\n", root_dir); |
220 | printf("Using root directory: %s\n", root_dir); |
Line 224... | Line 255... | ||
224 | char* s = strstr(argv[i], "="); |
255 | char* s = strstr(argv[i], "="); |
225 | harness_game_config.physics_step_time = atof(s + 1); |
256 | harness_game_config.physics_step_time = atof(s + 1); |
226 | LOG_INFO("Physics step time set to %f", harness_game_config.physics_step_time); |
257 | LOG_INFO("Physics step time set to %f", harness_game_config.physics_step_time); |
227 | handled = 1; |
258 | handled = 1; |
228 | } else if (strstr(argv[i], "--fps=") != NULL) { |
259 | } else if (strstr(argv[i], "--fps=") != NULL) { |
229 | char* s = strstr(argv[i], "="); |
260 | char* s = strstr(argv[i], "="); |
230 | harness_game_config.fps = atoi(s + 1); |
261 | harness_game_config.fps = atoi(s + 1); |
231 | LOG_INFO("FPS limiter set to %f", harness_game_config.fps); |
262 | LOG_INFO("FPS limiter set to %f", harness_game_config.fps); |
232 | handled = 1; |
263 | handled = 1; |
233 | } else if (strcasecmp(argv[i], "--freeze-timer") == 0) { |
264 | } else if (strcasecmp(argv[i], "--freeze-timer") == 0) { |
234 | LOG_INFO("Timer frozen"); |
265 | LOG_INFO("Timer frozen"); |
Line 255... | Line 286... | ||
255 | LOG_INFO("Volume multiplier set to %f", harness_game_config.volume_multiplier); |
286 | LOG_INFO("Volume multiplier set to %f", harness_game_config.volume_multiplier); |
256 | handled = 1; |
287 | handled = 1; |
257 | } else if (strcasecmp(argv[i], "--full-screen") == 0) { |
288 | } else if (strcasecmp(argv[i], "--full-screen") == 0) { |
258 | harness_game_config.start_full_screen = 1; |
289 | harness_game_config.start_full_screen = 1; |
259 | handled = 1; |
290 | handled = 1; |
260 | } else if (strcasecmp(argv[i], "-- |
291 | } else if (strcasecmp(argv[i], "--gore-check") == 0) { |
261 | harness_game_config. |
292 | harness_game_config.gore_check = 1; |
- | 293 | handled = 1; |
|
- | 294 | } else if (strcasecmp(argv[i], "--no-sound-options") == 0) { // Pierre-Marie Baty -- invert option default value |
|
- | 295 | harness_game_config.sound_options = 0; // Pierre-Marie Baty -- invert option default value |
|
262 | handled = 1; |
296 | handled = 1; |
263 | } else if (strcasecmp(argv[i], "--no-bind") == 0) { |
297 | } else if (strcasecmp(argv[i], "--no-bind") == 0) { |
264 | harness_game_config.no_bind = 1; |
298 | harness_game_config.no_bind = 1; |
265 | handled = 1; |
299 | handled = 1; |
266 | } |
300 | } |