| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * |
| 21 | * Linux Main and any Linux specific code that MUST be in the main application |
| 22 | * goes here. |
| 23 | * $NoKeywords: $ |
| 24 | */ |
| 25 | |
| 26 | #include <cstdlib> |
| 27 | #include <cstring> |
| 28 | #include <filesystem> |
| 29 | |
| 30 | #ifndef WIN32 |
| 31 | #include <unistd.h> |
| 32 | #include <csignal> |
| 33 | #endif |
| 34 | |
| 35 | #include <SDL.h> |
| 36 | |
| 37 | #include "program.h"cxx . . $ `<file>/Descent3/program.h`/ |
| 38 | #include "dedicated_server.h"cxx . . $ `<file>/lib/dedicated_server.h`/ |
| 39 | #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/ |
| 40 | #include "application.h"cxx . . $ `<file>/lib/application.h`/ |
| 41 | #include "appdatabase.h"cxx . . $ `<file>/lib/appdatabase.h`/ |
| 42 | #include "args.h"cxx . . $ `<file>/Descent3/args.h`/ |
| 43 | #include "init.h"cxx . . $ `<file>/Descent3/init.h`/ |
| 44 | #include "debug.h"cxx . . $ `<file>/ddebug/debug.h`/ |
| 45 | |
| 46 | #include "osiris_dll.h"cxx . . $ `<file>/Descent3/osiris_dll.h`/ |
| 47 | |
| 48 | #include "log.h"cxx . . $ `<file>/misc/log.h`/ |
| 49 | |
| 50 | extern bool ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed.; |
| 51 | |
| 52 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# orig_pwdcxx . . $ orig_pwd.; |
| 53 | |
| 54 | bool linux_permit_gammacxx . . $ linux_permit_gamma. = false; |
| 55 | |
| 56 | static volatile char already_tried_signal_cleanupcxx . . $ already_tried_signal_cleanup. = 0; |
| 57 | |
| 58 | void ddio_InternalClosecxx . . $ ddio_InternalClose(49f6e7a06ebc5aa8).(); // needed for emergency cleanup. |
| 59 | |
| 60 | void just_exitcxx . . $ just_exit(49f6e7a06ebc5aa8).(void) { |
| 61 | ddio_InternalClosecxx . . $ ddio_InternalClose(49f6e7a06ebc5aa8).(); // try to reset serial port. |
| 62 | |
| 63 | SDL_Quit(); |
| 64 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 65 | sync(); // just in case. |
| 66 | #endif |
| 67 | _exit(0); |
| 68 | } |
| 69 | |
| 70 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 71 | void fatal_signal_handlercxx . . $ fatal_signal_handler(d4f767463ce0a6b3).(int signum) { |
| 72 | switch (signum) { |
| 73 | case SIGHUPcxx . . $ `<external>/11773118241360591791/signum-generic.h:56:9`!: |
| 74 | case SIGTRAPcxx . . $ `<external>/11773118241360591791/signum-generic.h:58:9`!: |
| 75 | case SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!: |
| 76 | case SIGBUScxx . . $ `<external>/1457673850468744829/signum-arch.h:33:9`!: |
| 77 | case SIGFPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:51:9`!: |
| 78 | case SIGILLcxx . . $ `<external>/11773118241360591791/signum-generic.h:49:9`!: |
| 79 | case SIGQUITcxx . . $ `<external>/11773118241360591791/signum-generic.h:57:9`!: |
| 80 | case SIGSEGVcxx . . $ `<external>/11773118241360591791/signum-generic.h:52:9`!: |
| 81 | case SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!: |
| 82 | case SIGVTALRMcxx . . $ `<external>/1457673850468744829/signum-arch.h:47:9`!: |
| 83 | case SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!: |
| 84 | if (already_tried_signal_cleanupcxx . . $ already_tried_signal_cleanup.) |
| 85 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Recursive signal cleanup! Hard exit! AHHGGGG!\n"); |
| 86 | else { |
| 87 | already_tried_signal_cleanupcxx . . $ already_tried_signal_cleanup. = 1; |
| 88 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIGNAL %d caught, aborting\n", signum); |
| 89 | just_exitcxx . . $ just_exit(49f6e7a06ebc5aa8).(); |
| 90 | } // else |
| 91 | break; |
| 92 | case SIGXCPUcxx . . $ `<external>/1457673850468744829/signum-arch.h:46:9`!: |
| 93 | case SIGXFSZcxx . . $ `<external>/1457673850468744829/signum-arch.h:45:9`!: |
| 94 | break; |
| 95 | } |
| 96 | |
| 97 | _exit(-10); |
| 98 | } |
| 99 | |
| 100 | void safe_signal_handlercxx . . $ safe_signal_handler(d4f767463ce0a6b3).(int signum) {} |
| 101 | |
| 102 | void install_signal_handlerscxx . . $ install_signal_handlers(49f6e7a06ebc5aa8).() { |
| 103 | struct sigaction sact, fact; |
| 104 | |
| 105 | memset(&sact, 0, sizeof(sact)); |
| 106 | memset(&fact, 0, sizeof(fact)); |
| 107 | sact.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = safe_signal_handlercxx . . $ safe_signal_handler(d4f767463ce0a6b3).; |
| 108 | fact.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = fatal_signal_handlercxx . . $ fatal_signal_handler(d4f767463ce0a6b3).; |
| 109 | |
| 110 | if (sigaction(SIGHUPcxx . . $ `<external>/11773118241360591791/signum-generic.h:56:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 111 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGHUP\n"); |
| 112 | if (sigaction(SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 113 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGABRT\n"); |
| 114 | if (sigaction(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 115 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGINT\n"); |
| 116 | if (sigaction(SIGBUScxx . . $ `<external>/1457673850468744829/signum-arch.h:33:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 117 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGBUS\n"); |
| 118 | if (sigaction(SIGFPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:51:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 119 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGFPE\n"); |
| 120 | if (sigaction(SIGILLcxx . . $ `<external>/11773118241360591791/signum-generic.h:49:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 121 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGILL\n"); |
| 122 | if (sigaction(SIGQUITcxx . . $ `<external>/11773118241360591791/signum-generic.h:57:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 123 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGQUIT\n"); |
| 124 | if (sigaction(SIGSEGVcxx . . $ `<external>/11773118241360591791/signum-generic.h:52:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 125 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGSEGV\n"); |
| 126 | if (sigaction(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 127 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGTERM\n"); |
| 128 | if (sigaction(SIGXCPUcxx . . $ `<external>/1457673850468744829/signum-arch.h:46:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 129 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGXCPU\n"); |
| 130 | if (sigaction(SIGXFSZcxx . . $ `<external>/1457673850468744829/signum-arch.h:45:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 131 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGXFSZ\n"); |
| 132 | if (sigaction(SIGVTALRMcxx . . $ `<external>/1457673850468744829/signum-arch.h:47:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 133 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGVTALRM\n"); |
| 134 | if (sigaction(SIGTRAPcxx . . $ `<external>/11773118241360591791/signum-generic.h:58:9`!, &fact, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 135 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SIG: Unable to install SIGTRAP\n"); |
| 136 | } |
| 137 | #else |
| 138 | void install_signal_handlers() { |
| 139 | SetUnhandledExceptionFilter(RecordExceptionInfo); |
| 140 | } |
| 141 | #endif |
| 142 | |
| 143 | // --------------------------------------------------------------------------- |
| 144 | // Define our operating system specific extensions to the gameos system |
| 145 | // --------------------------------------------------------------------------- |
| 146 | class oeD3LnxAppcxx . . $ oeD3LnxApp# : public oeLnxApplicationcxx . . $ oeLnxApplication# { |
| 147 | bool shutdowncxx . . $ oeD3LnxApp#shutdown., final_shutdowncxx . . $ oeD3LnxApp#final_shutdown.; |
| 148 | int old_screen_modecxx . . $ oeD3LnxApp#old_screen_mode.; |
| 149 | |
| 150 | public: |
| 151 | oeD3LnxAppcxx . . $ oeD3LnxApp#oeD3LnxApp(cb2f890c2fdad230).(unsigned flags) : oeLnxApplicationcxx . . $ oeLnxApplication#(flags) { |
| 152 | Descentcxx . . $ Descent. = this; |
| 153 | shutdowncxx . . $ oeD3LnxApp#shutdown. = false; |
| 154 | final_shutdowncxx . . $ oeD3LnxApp#final_shutdown. = false; |
| 155 | } |
| 156 | virtual ~cxx . . $ oeD3LnxApp#`~oeD3LnxApp`(ced63f7c635d850d).oeD3LnxAppcxx . . $ oeD3LnxApp#() { final_shutdowncxx . . $ oeD3LnxApp#final_shutdown. = true; }; |
| 157 | |
| 158 | void runcxx . . $ oeD3LnxApp#run(49f6e7a06ebc5aa8).() { Descent3cxx . . $ Descent3(49f6e7a06ebc5aa8).(); }; |
| 159 | }; |
| 160 | |
| 161 | class oeD3LnxDatabasecxx . . $ oeD3LnxDatabase# : public oeLnxAppDatabasecxx . . $ oeLnxAppDatabase# { |
| 162 | public: |
| 163 | oeD3LnxDatabasecxx . . $ oeD3LnxDatabase#oeD3LnxDatabase(49f6e7a06ebc5aa8).() { |
| 164 | char path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 165 | char netpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 166 | |
| 167 | // put directories into database |
| 168 | |
| 169 | #ifdef EDITOR |
| 170 | create_record("D3Edit"); |
| 171 | #else |
| 172 | create_recordcxx . . $ oeLnxAppDatabase#create_record(c5f7da30cbc0f4e9).("Descent3"); |
| 173 | #endif |
| 174 | |
| 175 | char *dir = getenvcxx . . $ getenv(c63359b659779399).("D3_LOCAL"); |
| 176 | char *netdir = getenvcxx . . $ getenv(c63359b659779399).("D3_DIR"); |
| 177 | |
| 178 | if (!dir) |
| 179 | strcpy(path, Base_directorycxx . . $ Base_directory.); |
| 180 | else |
| 181 | strcpy(path, dir); |
| 182 | |
| 183 | if (!netdir) |
| 184 | strcpy(netpath, ""); |
| 185 | else |
| 186 | strcpy(netpath, netdir); |
| 187 | |
| 188 | writecxx . . $ oeLnxAppDatabase#write(f827cee075336303).("local directory", path, strlen(path) + 1); |
| 189 | writecxx . . $ oeLnxAppDatabase#write(f827cee075336303).("net directory", netpath, strlen(netpath) + 1); |
| 190 | Databasecxx . . $ Database. = this; |
| 191 | } |
| 192 | }; |
| 193 | |
| 194 | int sdlKeyFiltercxx . . $ sdlKeyFilter(5d4fa56947397a26).(const SDL_Event *event); |
| 195 | int sdlMouseButtonUpFiltercxx . . $ sdlMouseButtonUpFilter(5d4fa56947397a26).(const SDL_Event *event); |
| 196 | int sdlMouseButtonDownFiltercxx . . $ sdlMouseButtonDownFilter(5d4fa56947397a26).(const SDL_Event *event); |
| 197 | int sdlMouseWheelFiltercxx . . $ sdlMouseWheelFilter(5d4fa56947397a26).(const SDL_Event *event); |
| 198 | int sdlMouseMotionFiltercxx . . $ sdlMouseMotionFilter(5d4fa56947397a26).(const SDL_Event *event); |
| 199 | |
| 200 | int SDLCALLcxx . . $ `/usr/include/SDL2/begin_code.h:87:9`! d3SDLEventFiltercxx . . $ d3SDLEventFilter(c0128bf54fa871fa).(void *userdata, SDL_Event *event) { |
| 201 | switch (event->type) { |
| 202 | case SDL_KEYUP: |
| 203 | case SDL_KEYDOWN: |
| 204 | return (sdlKeyFiltercxx . . $ sdlKeyFilter(5d4fa56947397a26).(event)); |
| 205 | case SDL_JOYBALLMOTION: |
| 206 | case SDL_MOUSEMOTION: |
| 207 | return (sdlMouseMotionFiltercxx . . $ sdlMouseMotionFilter(5d4fa56947397a26).(event)); |
| 208 | case SDL_MOUSEBUTTONUP: |
| 209 | return (sdlMouseButtonUpFiltercxx . . $ sdlMouseButtonUpFilter(5d4fa56947397a26).(event)); |
| 210 | case SDL_MOUSEBUTTONDOWN: |
| 211 | return (sdlMouseButtonDownFiltercxx . . $ sdlMouseButtonDownFilter(5d4fa56947397a26).(event)); |
| 212 | case SDL_MOUSEWHEEL: |
| 213 | return (sdlMouseWheelFiltercxx . . $ sdlMouseWheelFilter(5d4fa56947397a26).(event)); |
| 214 | case SDL_QUIT: |
| 215 | SDL_Quit(); |
| 216 | _exit(0); |
| 217 | break; |
| 218 | default: |
| 219 | break; |
| 220 | } // switch |
| 221 | |
| 222 | return (1); |
| 223 | } |
| 224 | |
| 225 | // --------------------------------------------------------------------------- |
| 226 | // Main |
| 227 | // creates all the OS objects and then runs Descent 3. |
| 228 | // this is all this function should do. |
| 229 | // --------------------------------------------------------------------------- |
| 230 | #ifdef WIN32 |
| 231 | int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nCmdShow) { |
| 232 | strupr(szCmdLine); |
| 233 | GatherArgs(szCmdLine); |
| 234 | #else |
| 235 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) { |
| 236 | GatherArgscxx . . $ GatherArgs(3ed91490e421178f).(argv); |
| 237 | #endif |
| 238 | |
| 239 | orig_pwdcxx . . $ orig_pwd. =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::current_pathcxx . . $ std/filesystem/current_path(4c12bfa3c403d782).(); |
| 240 | |
| 241 | /* Setup the logging system */ |
| 242 | InitLogcxx . . $ InitLog(49f6e7a06ebc5aa8).(); |
| 243 | |
| 244 | setbuf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 245 | setbuf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 246 | |
| 247 | #ifdef DEDICATED |
| 248 | setenv("SDL_VIDEODRIVER", "dummy", 1); |
| 249 | #endif |
| 250 | |
| 251 | int rc = SDL_Init(SDL_INIT_AUDIOcxx . . $ `<external>/13597568925221565411/SDL.h:84:9`! | SDL_INIT_VIDEOcxx . . $ `<external>/13597568925221565411/SDL.h:85:9`!); |
| 252 | if (rc != 0) { |
| 253 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SDL: SDL_Init() failed! rc == (%d).\n", rc); |
| 254 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SDL_GetError() reports \"%s\".\n", SDL_GetError()); |
| 255 | return (0); |
| 256 | } |
| 257 | |
| 258 | // !!! FIXME: Don't use an event filter! |
| 259 | SDL_SetEventFilter(d3SDLEventFiltercxx . . $ d3SDLEventFilter(c0128bf54fa871fa)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 260 | install_signal_handlerscxx . . $ install_signal_handlers(49f6e7a06ebc5aa8).(); |
| 261 | |
| 262 | int winArg = FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-windowed", 'w'); |
| 263 | int fsArg = FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-fullscreen", 'f'); |
| 264 | |
| 265 | if ((fsArg) && (winArg)) { |
| 266 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: %s AND %s specified!\n", GameArgscxx . . $ GameArgs.[winArg], GameArgscxx . . $ GameArgs.[fsArg]); |
| 267 | return (0); |
| 268 | } // if |
| 269 | |
| 270 | if (FindArgcxx . . $ FindArg(5c4306d8553b3696).("-game_checksum")) { |
| 271 | extern tOSIRISModuleInitcxx . . $ tOSIRISModuleInit# Osiris_module_initcxx . . $ Osiris_module_init.; |
| 272 | extern void Osiris_CreateModuleInitStructcxx . . $ Osiris_CreateModuleInitStruct(5a9437a4d944b175).(tOSIRISModuleInitcxx . . $ tOSIRISModuleInit# * st); |
| 273 | extern uint32_tcxx . . $ uint32_t# Osiris_CreateGameChecksumcxx . . $ Osiris_CreateGameChecksum(db52760e79bf9054).(void); |
| 274 | |
| 275 | Osiris_CreateModuleInitStructcxx . . $ Osiris_CreateModuleInitStruct(5a9437a4d944b175).(&Osiris_module_initcxx . . $ Osiris_module_init.); |
| 276 | uint32_tcxx . . $ uint32_t# checksum = Osiris_CreateGameChecksumcxx . . $ Osiris_CreateGameChecksum(db52760e79bf9054).(); |
| 277 | printf("Descent 3\n"); |
| 278 | printf("Game Checksum: %u\n", checksum); |
| 279 | return (0); |
| 280 | } else { |
| 281 | /*initialize our OS Object. This could be a game dependant OS object, or a default OS object. |
| 282 | once we create it, if successful, we can start the game. |
| 283 | */ |
| 284 | int flags = 0; |
| 285 | |
| 286 | if (!FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-dedicated", 'd')) { |
| 287 | #ifndef DEDICATED |
| 288 | // check for a renderer |
| 289 | |
| 290 | if ((FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-windowed", 'w')) && (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-fullscreen", 'f'))) { |
| 291 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: Both windowed and fullscreen mode requested."); |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | if (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-nomousegrab", 'm')) { |
| 296 | flags |= APPFLAG_NOMOUSECAPTUREcxx . . $ `linux/lnxapp.h:29:9`!; |
| 297 | } |
| 298 | |
| 299 | ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed. = (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-nomousegrab", 'm') == 0); |
| 300 | |
| 301 | if (!FindArgcxx . . $ FindArg(5c4306d8553b3696).("-sharedmemory")) { |
| 302 | flags |= APPFLAG_NOSHAREDMEMORYcxx . . $ `linux/lnxapp.h:30:9`!; |
| 303 | } |
| 304 | flags |= APPFLAG_WINDOWEDMODEcxx . . $ `linux/lnxapp.h:31:9`!; |
| 305 | |
| 306 | if (!FindArgcxx . . $ FindArg(5c4306d8553b3696).("-nodgamouse")) { |
| 307 | flags |= APPFLAG_DGAMOUSEcxx . . $ `linux/lnxapp.h:32:9`!; |
| 308 | } |
| 309 | #else |
| 310 | fprintf(stderr, "Error: \"--dedicated\" or \"-d\" flag required\n"); |
| 311 | return 0; |
| 312 | #endif |
| 313 | |
| 314 | } else { |
| 315 | // Dedicated Server Mode |
| 316 | flags |= OEAPP_CONSOLEcxx . . $ OEAPP_CONSOLE.; |
| 317 | |
| 318 | // service flag overrides others here in the group |
| 319 | if (FindArgcxx . . $ FindArg(5c4306d8553b3696).("-service")) { |
| 320 | flags |= APPFLAG_USESERVICEcxx . . $ `linux/lnxapp.h:27:9`!; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | bool run_d3 = true; |
| 325 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 326 | if (flags & APPFLAG_USESERVICEcxx . . $ `linux/lnxapp.h:27:9`!) { |
| 327 | run_d3 = false; |
| 328 | pid_t np = fork(); |
| 329 | if (np == -1) { |
| 330 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unable to fork process\n"); |
| 331 | } |
| 332 | if (np == 0) { |
| 333 | run_d3 = true; |
| 334 | np = setsid(); |
| 335 | pid_t pp = getpid(); |
| 336 | printf("Successfully forked process [new sid=%d pid=%d]\n", np, pp); |
| 337 | } |
| 338 | } |
| 339 | #endif |
| 340 | |
| 341 | if (run_d3) { |
| 342 | oeD3LnxAppcxx . . $ oeD3LnxApp# d3cxx . . $ oeD3LnxApp#oeD3LnxApp(cb2f890c2fdad230).(flags); |
| 343 | oeD3LnxDatabasecxx . . $ oeD3LnxDatabase# dbasecxx . . $ oeD3LnxDatabase#oeD3LnxDatabase(49f6e7a06ebc5aa8).; |
| 344 | StartDedicatedServercxx . . $ StartDedicatedServer(49f6e7a06ebc5aa8).(); |
| 345 | PreInitD3Systemscxx . . $ PreInitD3Systems(49f6e7a06ebc5aa8).(); |
| 346 | |
| 347 | d3.initcxx . . $ oeLnxApplication#init(49f6e7a06ebc5aa8).(); |
| 348 | d3.runcxx . . $ oeD3LnxApp#run(49f6e7a06ebc5aa8).(); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | just_exitcxx . . $ just_exit(49f6e7a06ebc5aa8).(); |
| 353 | return 0; |
| 354 | } |