summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorIndrajith K L2025-11-09 16:12:20 +0530
committerIndrajith K L2025-11-09 16:12:20 +0530
commit8c9367f3689aee05d33fc1cae8a5d1aa6d2b5fb8 (patch)
tree94ab60d8a0dd939478f9b2838bdc6c1d693cb9a8 /src/main.c
parent0fbc961bb8e7b9864c0982bb86b0de2e25d6f4aa (diff)
downloadreilua-enhanced-8c9367f3689aee05d33fc1cae8a5d1aa6d2b5fb8.tar.gz
reilua-enhanced-8c9367f3689aee05d33fc1cae8a5d1aa6d2b5fb8.tar.bz2
reilua-enhanced-8c9367f3689aee05d33fc1cae8a5d1aa6d2b5fb8.zip
Add game folder workflow, custom executable names, cross-platform tasks, and logging controls
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 72dbdca..19a49a3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,12 +33,14 @@ int main( int argn, const char** argc ) {
bool interpret_mode = false;
bool show_console = false;
bool skip_splash = false;
+ bool enable_logging = false;
#ifdef _WIN32
/* Check for --log and --no-logo arguments */
for ( int i = 1; i < argn; i++ ) {
if ( strcmp( argc[i], "--log" ) == 0 ) {
show_console = true;
+ enable_logging = true;
}
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
skip_splash = true;
@@ -59,11 +61,13 @@ int main( int argn, const char** argc ) {
FreeConsole();
}
#else
- /* Check for --no-logo on non-Windows platforms */
+ /* Check for --no-logo and --log on non-Windows platforms */
for ( int i = 1; i < argn; i++ ) {
if ( strcmp( argc[i], "--no-logo" ) == 0 ) {
skip_splash = true;
- break;
+ }
+ if ( strcmp( argc[i], "--log" ) == 0 ) {
+ enable_logging = true;
}
}
#endif
@@ -96,26 +100,44 @@ int main( int argn, const char** argc ) {
else {
/* Only flags were provided, use default path search */
char testPath[ STRING_LEN ] = { '\0' };
- sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
+ /* Check for game/main.lua in working directory */
+ sprintf( testPath, "%s/game/main.lua", GetWorkingDirectory() );
if ( FileExists( testPath ) ) {
- sprintf( basePath, "%s", GetWorkingDirectory() );
+ sprintf( basePath, "%s/game/", GetWorkingDirectory() );
}
+ /* Check for main.lua in working directory */
else {
- sprintf( basePath, "%s", GetApplicationDirectory() );
+ sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
+ if ( FileExists( testPath ) ) {
+ sprintf( basePath, "%s", GetWorkingDirectory() );
+ }
+ /* Check exe directory */
+ else {
+ sprintf( basePath, "%s", GetApplicationDirectory() );
+ }
}
}
}
- /* If no argument given, check current directory first, then exe directory. */
+ /* If no argument given, check game folder first, then current directory, then exe directory. */
else {
char testPath[ STRING_LEN ] = { '\0' };
- sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
+ /* Check for game/main.lua in working directory */
+ sprintf( testPath, "%s/game/main.lua", GetWorkingDirectory() );
if ( FileExists( testPath ) ) {
- sprintf( basePath, "%s", GetWorkingDirectory() );
+ sprintf( basePath, "%s/game/", GetWorkingDirectory() );
}
+ /* Check for main.lua in working directory */
else {
- sprintf( basePath, "%s", GetApplicationDirectory() );
+ sprintf( testPath, "%s/main.lua", GetWorkingDirectory() );
+ if ( FileExists( testPath ) ) {
+ sprintf( basePath, "%s", GetWorkingDirectory() );
+ }
+ /* Check exe directory */
+ else {
+ sprintf( basePath, "%s", GetApplicationDirectory() );
+ }
}
}
@@ -135,7 +157,7 @@ int main( int argn, const char** argc ) {
}
else {
printVersion();
- stateInit( argn, argc, basePath );
+ stateInit( argn, argc, basePath, enable_logging );
/* Show splash screens if not skipped */
if ( !skip_splash ) {