Skip to content

Commit

Permalink
fix for segmentation fault on runtime (Linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitedragon0000 committed Jul 19, 2018
1 parent 7b08006 commit 4b1705f
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 84 deletions.
126 changes: 63 additions & 63 deletions engine/openbor.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion engine/openbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3087,7 +3087,7 @@ int ai_check_grab();
int ai_check_escape();
int ai_check_busy();
void display_credits(void);
void shutdown(int status, char *msg, ...);
void borShutdown(int status, char *msg, ...);
#ifdef DC
void guistartup(void);
#endif
Expand Down
10 changes: 5 additions & 5 deletions engine/openborscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static void execute_init_method(Script *pdest, int iscopy, int localclear)
pdest->pinterpreter->pCurrentInstruction = pdest->pinterpreter->pInitEntry;
if(FAILED( Interpreter_EvaluateCall(pdest->pinterpreter)))
{
shutdown(1, "Fatal: failed to execute 'init' in script %s %s", pdest->pinterpreter->theSymbolTable.name, pdest->comment ? pdest->comment : "");
borShutdown(1, "Fatal: failed to execute 'init' in script %s %s", pdest->pinterpreter->theSymbolTable.name, pdest->comment ? pdest->comment : "");
}
pdest->pinterpreter->bReset = FALSE; // not needed, perhaps
ScriptVariant_Clear(&tempvar);
Expand Down Expand Up @@ -525,7 +525,7 @@ void Script_Clear(Script *pscript, int localclear)
pscript->pinterpreter->pCurrentInstruction = pscript->pinterpreter->pClearEntry;
if(FAILED( Interpreter_EvaluateCall(pscript->pinterpreter)))
{
shutdown(1, "Fatal: failed to execute 'clear' in script %s %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
borShutdown(1, "Fatal: failed to execute 'clear' in script %s %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
}
pscript->pinterpreter->bReset = FALSE; // not needed, perhaps
ScriptVariant_Clear(&tempvar);
Expand Down Expand Up @@ -622,7 +622,7 @@ int Script_Compile(Script *pscript)
result = SUCCEEDED(Interpreter_CompileInstructions(pscript->pinterpreter));
if(!result)
{
shutdown(1, "Can't compile script '%s' %s\n", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
borShutdown(1, "Can't compile script '%s' %s\n", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
}

pscript->pinterpreter->bReset = FALSE;
Expand Down Expand Up @@ -670,7 +670,7 @@ int Script_Execute(Script *pscript)
pcurrentscript = temp;
if(!result)
{
shutdown(1, "There's an exception while executing script '%s' %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
borShutdown(1, "There's an exception while executing script '%s' %s", pscript->pinterpreter->theSymbolTable.name, pscript->comment ? pscript->comment : "");
}
return result;
}
Expand Down Expand Up @@ -12627,7 +12627,7 @@ HRESULT openbor_shutdown(ScriptVariant **varlist , ScriptVariant **pretvar, int
goto shutdown_error;
}

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

return S_OK;
shutdown_error:
Expand Down
2 changes: 1 addition & 1 deletion engine/sdl/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void getPads(Uint8* keystate, Uint8* keystate_def)
break;
#endif
case SDL_QUIT:
shutdown(0, DEFAULT_SHUTDOWN_MESSAGE);
borShutdown(0, DEFAULT_SHUTDOWN_MESSAGE);
break;

case SDL_JOYBUTTONUP:
Expand Down
2 changes: 1 addition & 1 deletion engine/source/gamelib/translation.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static char *__consume_str(char *buf, ptrdiff_t *pos, size_t size)

if(stron)
{
shutdown(1, "Unterminated string in translation.txt.");
borShutdown(1, "Unterminated string in translation.txt.");
}
//TODO: free pointers
result[len] = 0;
Expand Down
12 changes: 3 additions & 9 deletions engine/source/preprocessorlib/pp_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,20 @@
#include "pp_expr.h"
#include "borendian.h"

/*#if PP_TEST // using pp_test.c to test the preprocessor functionality; OpenBOR functionality is not available
#if PP_TEST // using pp_test.c to test the preprocessor functionality; OpenBOR functionality is not available
#undef printf
#define openpackfile(fname, pname) ((int)fopen(fname, "rb"))
#define readpackfile(hnd, buf, len) fread(buf, 1, len, (FILE*)hnd)
#define seekpackfile(hnd, loc, md) fseek((FILE*)hnd, loc, md)
#define tellpackfile(hnd) ftell((FILE*)hnd)
#define closepackfile(hnd) fclose((FILE*)hnd)
#define printf(msg, args...) fprintf(stderr, msg, ##args)
#define shutdown(ret, msg, args...) { fprintf(stderr, msg, ##args); exit(ret); }
#define borShutdown(ret, msg, args...) { fprintf(stderr, msg, ##args); exit(ret); }
extern char *get_full_path(char *filename);
#else // otherwise, we can use OpenBOR functionality like writeToLogFile
#include "openbor.h"
#include "globals.h"
#include "packfile.h"
#define tellpackfile(hnd) seekpackfile(hnd, 0, SEEK_CUR)
#undef time
#endif*/

#include "packfile.h"
#define tellpackfile(hnd) seekpackfile(hnd, 0, SEEK_CUR)
#endif

/**
* Initializes a preprocessor context. Assumes that this context either hasn't
Expand Down
2 changes: 1 addition & 1 deletion engine/source/scriptlib/ScriptVariant.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void ScriptVariant_Copy(ScriptVariant *svar, ScriptVariant *rightChild )
break;
default:
//should not happen unless the variant is not intialized correctly
//shutdown(1, "invalid variant type");
//borShutdown(1, "invalid variant type");
svar->ptrVal = NULL;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions engine/source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void Array_Check_Size( const char *f_caller, char **array, int new_size, int *cu
*array = malloc(*curr_size_allocated );
if( *array == NULL)
{
shutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
borShutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
}
memset( *array, 0, *curr_size_allocated );
return;
Expand All @@ -675,7 +675,7 @@ void Array_Check_Size( const char *f_caller, char **array, int new_size, int *cu
void *copy = malloc(*curr_size_allocated );
if(copy == NULL)
{
shutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
borShutdown(1, "Out Of Memory! Failed in %s\n", f_caller);
}

// Copy the previous content of the array
Expand Down
2 changes: 1 addition & 1 deletion engine/wii/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void wiimote_poweroff(int playernum)
// Resetting returns to the Homebrew Channel.
void respondToPowerReset()
{
shutdown(hwbutton, DEFAULT_SHUTDOWN_MESSAGE);
borShutdown(hwbutton, DEFAULT_SHUTDOWN_MESSAGE);
}

static int flag_to_index(unsigned long flag)
Expand Down

0 comments on commit 4b1705f

Please sign in to comment.