Skip to content

Commit 4b1705f

Browse files
author
White Dragon
committed
fix for segmentation fault on runtime (Linux)
1 parent 7b08006 commit 4b1705f

9 files changed

Lines changed: 78 additions & 84 deletions

File tree

engine/openbor.c

Lines changed: 63 additions & 63 deletions
Large diffs are not rendered by default.

engine/openbor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3087,7 +3087,7 @@ int ai_check_grab();
30873087
int ai_check_escape();
30883088
int ai_check_busy();
30893089
void display_credits(void);
3090-
void shutdown(int status, char *msg, ...);
3090+
void borShutdown(int status, char *msg, ...);
30913091
#ifdef DC
30923092
void guistartup(void);
30933093
#endif

engine/openborscript.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static void execute_init_method(Script *pdest, int iscopy, int localclear)
477477
pdest->pinterpreter->pCurrentInstruction = pdest->pinterpreter->pInitEntry;
478478
if(FAILED( Interpreter_EvaluateCall(pdest->pinterpreter)))
479479
{
480-
shutdown(1, "Fatal: failed to execute 'init' in script %s %s", pdest->pinterpreter->theSymbolTable.name, pdest->comment ? pdest->comment : "");
480+
borShutdown(1, "Fatal: failed to execute 'init' in script %s %s", pdest->pinterpreter->theSymbolTable.name, pdest->comment ? pdest->comment : "");
481481
}
482482
pdest->pinterpreter->bReset = FALSE; // not needed, perhaps
483483
ScriptVariant_Clear(&tempvar);
@@ -525,7 +525,7 @@ void Script_Clear(Script *pscript, int localclear)
525525
pscript->pinterpreter->pCurrentInstruction = pscript->pinterpreter->pClearEntry;
526526
if(FAILED( Interpreter_EvaluateCall(pscript->pinterpreter)))
527527
{
528-
shutdown(1, "Fatal: failed to execute 'clear' in script %s %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
528+
borShutdown(1, "Fatal: failed to execute 'clear' in script %s %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
529529
}
530530
pscript->pinterpreter->bReset = FALSE; // not needed, perhaps
531531
ScriptVariant_Clear(&tempvar);
@@ -622,7 +622,7 @@ int Script_Compile(Script *pscript)
622622
result = SUCCEEDED(Interpreter_CompileInstructions(pscript->pinterpreter));
623623
if(!result)
624624
{
625-
shutdown(1, "Can't compile script '%s' %s\n", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
625+
borShutdown(1, "Can't compile script '%s' %s\n", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
626626
}
627627

628628
pscript->pinterpreter->bReset = FALSE;
@@ -670,7 +670,7 @@ int Script_Execute(Script *pscript)
670670
pcurrentscript = temp;
671671
if(!result)
672672
{
673-
shutdown(1, "There's an exception while executing script '%s' %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
673+
borShutdown(1, "There's an exception while executing script '%s' %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
674674
}
675675
return result;
676676
}
@@ -12627,7 +12627,7 @@ HRESULT openbor_shutdown(ScriptVariant **varlist , ScriptVariant **pretvar, int
1262712627
goto shutdown_error;
1262812628
}
1262912629

12630-
shutdown((LONG)ltemp, paramCount > 1 ? StrCache_Get(varlist[1]->strVal) : (DEFAULT_SHUTDOWN_MESSAGE));
12630+
borShutdown((LONG)ltemp, paramCount > 1 ? StrCache_Get(varlist[1]->strVal) : (DEFAULT_SHUTDOWN_MESSAGE));
1263112631

1263212632
return S_OK;
1263312633
shutdown_error:

engine/sdl/control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void getPads(Uint8* keystate, Uint8* keystate_def)
143143
break;
144144
#endif
145145
case SDL_QUIT:
146-
shutdown(0, DEFAULT_SHUTDOWN_MESSAGE);
146+
borShutdown(0, DEFAULT_SHUTDOWN_MESSAGE);
147147
break;
148148

149149
case SDL_JOYBUTTONUP:

engine/source/gamelib/translation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static char *__consume_str(char *buf, ptrdiff_t *pos, size_t size)
7070

7171
if(stron)
7272
{
73-
shutdown(1, "Unterminated string in translation.txt.");
73+
borShutdown(1, "Unterminated string in translation.txt.");
7474
}
7575
//TODO: free pointers
7676
result[len] = 0;

engine/source/preprocessorlib/pp_parser.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,20 @@
2626
#include "pp_expr.h"
2727
#include "borendian.h"
2828

29-
/*#if PP_TEST // using pp_test.c to test the preprocessor functionality; OpenBOR functionality is not available
29+
#if PP_TEST // using pp_test.c to test the preprocessor functionality; OpenBOR functionality is not available
3030
#undef printf
3131
#define openpackfile(fname, pname) ((int)fopen(fname, "rb"))
3232
#define readpackfile(hnd, buf, len) fread(buf, 1, len, (FILE*)hnd)
3333
#define seekpackfile(hnd, loc, md) fseek((FILE*)hnd, loc, md)
3434
#define tellpackfile(hnd) ftell((FILE*)hnd)
3535
#define closepackfile(hnd) fclose((FILE*)hnd)
3636
#define printf(msg, args...) fprintf(stderr, msg, ##args)
37-
#define shutdown(ret, msg, args...) { fprintf(stderr, msg, ##args); exit(ret); }
37+
#define borShutdown(ret, msg, args...) { fprintf(stderr, msg, ##args); exit(ret); }
3838
extern char *get_full_path(char *filename);
3939
#else // otherwise, we can use OpenBOR functionality like writeToLogFile
40-
#include "openbor.h"
41-
#include "globals.h"
42-
#include "packfile.h"
43-
#define tellpackfile(hnd) seekpackfile(hnd, 0, SEEK_CUR)
44-
#undef time
45-
#endif*/
46-
4740
#include "packfile.h"
4841
#define tellpackfile(hnd) seekpackfile(hnd, 0, SEEK_CUR)
42+
#endif
4943

5044
/**
5145
* Initializes a preprocessor context. Assumes that this context either hasn't

engine/source/scriptlib/ScriptVariant.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ void ScriptVariant_Copy(ScriptVariant *svar, ScriptVariant *rightChild )
326326
break;
327327
default:
328328
//should not happen unless the variant is not intialized correctly
329-
//shutdown(1, "invalid variant type");
329+
//borShutdown(1, "invalid variant type");
330330
svar->ptrVal = NULL;
331331
break;
332332
}

engine/source/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ void Array_Check_Size( const char *f_caller, char **array, int new_size, int *cu
651651
*array = malloc(*curr_size_allocated );
652652
if( *array == NULL)
653653
{
654-
shutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
654+
borShutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
655655
}
656656
memset( *array, 0, *curr_size_allocated );
657657
return;
@@ -675,7 +675,7 @@ void Array_Check_Size( const char *f_caller, char **array, int new_size, int *cu
675675
void *copy = malloc(*curr_size_allocated );
676676
if(copy == NULL)
677677
{
678-
shutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
678+
borShutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
679679
}
680680

681681
// Copy the previous content of the array

engine/wii/control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void wiimote_poweroff(int playernum)
8181
// Resetting returns to the Homebrew Channel.
8282
void respondToPowerReset()
8383
{
84-
shutdown(hwbutton, DEFAULT_SHUTDOWN_MESSAGE);
84+
borShutdown(hwbutton, DEFAULT_SHUTDOWN_MESSAGE);
8585
}
8686

8787
static int flag_to_index(unsigned long flag)

0 commit comments

Comments
 (0)