Skip to content

Commit

Permalink
fixed crash when you load tic without any langs
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed May 25, 2024
1 parent 9a92615 commit 42047e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
39 changes: 17 additions & 22 deletions include/tic80_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,24 @@
// # endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */

#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# define TIC_MODULE_EXT ".dll"
# if defined(_MSC_VER) && defined(_USING_V110_SDK71_)
# define __TIC_WIN7__ 1
#if !defined(__LIBRETRO__)
# if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# define TIC_MODULE_EXT ".dll"
# if defined(_MSC_VER) && defined(_USING_V110_SDK71_)
# define __TIC_WIN7__ 1
# endif
# endif
# if defined(ANDROID) || defined(__ANDROID__)
# undef __TIC_ANDROID__
# define __TIC_ANDROID__ 1
# define TIC_MODULE_EXT ".so"
# elif (defined(linux) || defined(__linux) || defined(__linux__))
# undef __TIC_LINUX__
# define __TIC_LINUX__ 1
# define TIC_MODULE_EXT ".so"
# endif
#endif

#if defined(ANDROID) || defined(__ANDROID__)
# undef __TIC_ANDROID__
# define __TIC_ANDROID__ 1
# define TIC_MODULE_EXT ".so"
#elif (defined(linux) || defined(__linux) || defined(__linux__))
# undef __TIC_LINUX__
# define __TIC_LINUX__ 1
# define TIC_MODULE_EXT ".so"
#endif

#if defined(__LIBRETRO__)
#ifdef TIC_MODULE_EXT
#undef TIC_MODULE_EXT
#endif
#endif

#if defined(TIC_RUNTIME_STATIC)
Expand Down
4 changes: 3 additions & 1 deletion src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,7 @@ const tic_script* tic_get_script(tic_mem* memory)
return script;
}

return *Scripts;
static const tic_script empty;

return *Scripts ? *Scripts : ∅
}
11 changes: 7 additions & 4 deletions src/studio/screens/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,10 @@ static void loadCartSection(Console* console, const tic_cartridge* cart, const c
static char* getDemoCartPath(char* path, const tic_script* script)
{
strcpy(path, TIC_LOCAL_VERSION "default_");
strcat(path, script->name);

if(script && script->name)
strcat(path, script->name);

strcat(path, ".tic");

return path;
Expand Down Expand Up @@ -1216,7 +1219,7 @@ static void onNewCommandConfirmed(Console* console)
}
else if(count == 1)
{
loadDemo(console, *tic_scripts());
loadDemo(console, tic_get_script(console->tic));
done = true;
}
else if(console->desc->count)
Expand Down Expand Up @@ -1732,7 +1735,7 @@ static void onConfigCommand(Console* console)
{
if (console->desc->count == 1)
{
onLoadDemoCommand(console, *tic_scripts());
onLoadDemoCommand(console, tic_get_script(console->tic));
}
else
{
Expand Down Expand Up @@ -4313,7 +4316,7 @@ static void tick(Console* console)
{
if(!start->embed)
{
loadDemo(console, *tic_scripts());
loadDemo(console, tic_get_script(tic));

if(!console->args.cli)
{
Expand Down

0 comments on commit 42047e1

Please sign in to comment.