Skip to content

Commit

Permalink
Make sure unidiff have error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Apr 25, 2024
1 parent 0c9ad50 commit 5dd763e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/naev.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ void load_all( void )
missions_load();

loadscreen_update( ++stage / LOADING_STAGES, _( "Loading the UniDiffs…" ) );
diff_loadAvailable();
diff_init();

loadscreen_update( ++stage / LOADING_STAGES, _( "Populating Maps…" ) );
outfit_mapParse();
Expand Down Expand Up @@ -740,6 +740,7 @@ void unload_all( void )
npc_clear(); /* In case exiting while landed. */
background_free(); /* Destroy backgrounds. */
load_free(); /* Clean up loading game stuff stuff. */
diff_exit();
safelanes_destroy();
diff_free();
economy_destroy(); /* must be called before space_exit */
Expand Down
35 changes: 26 additions & 9 deletions src/unidiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,21 @@ static const char *diff_nav_hyperspace =
NULL; /**< Stores the player's hyperspace target if necessary. */

static const char *hunk_error[HUNK_TYPE_SENTINAL] = {
[HUNK_TYPE_SPOB_ADD] = N_( " [%s] spob add: '%s'" ),
[HUNK_TYPE_SPOB_REMOVE] = N_( " [%s] spob remove: '%s'" ),
[HUNK_TYPE_VSPOB_ADD] = N_( " [%s] virtual spob add: '%s'" ),
[HUNK_TYPE_VSPOB_REMOVE] = N_( " [%s] virtual spob remove: '%s'" ),
[HUNK_TYPE_JUMP_ADD] = N_( " [%s] jump add: '%s'" ),
[HUNK_TYPE_JUMP_REMOVE] = N_( " [%s] jump remove: '%s'" ),
[HUNK_TYPE_TECH_ADD] = N_( " [%s] tech add: '%s'" ),
[HUNK_TYPE_TECH_REMOVE] = N_( " [%s] tech remove: '%s'" ),
[HUNK_TYPE_NONE] = N_( " [%s] none: %s" ),
[HUNK_TYPE_SPOB_ADD] = N_( " [%s] spob add: '%s'" ),
[HUNK_TYPE_SPOB_REMOVE] = N_( " [%s] spob remove: '%s'" ),
[HUNK_TYPE_VSPOB_ADD] = N_( " [%s] virtual spob add: '%s'" ),
[HUNK_TYPE_VSPOB_REMOVE] = N_( " [%s] virtual spob remove: '%s'" ),
[HUNK_TYPE_JUMP_ADD] = N_( " [%s] jump add: '%s'" ),
[HUNK_TYPE_JUMP_REMOVE] = N_( " [%s] jump remove: '%s'" ),
[HUNK_TYPE_TECH_ADD] = N_( " [%s] tech add: '%s'" ),
[HUNK_TYPE_TECH_REMOVE] = N_( " [%s] tech remove: '%s'" ),
[HUNK_TYPE_SSYS_BACKGROUND] = N_( " [%s] ssys background: '%s'" ),
[HUNK_TYPE_SSYS_BACKGROUND_REVERT] =
N_( " [%s] ssys background revert: '%s'" ),
[HUNK_TYPE_SSYS_FEATURES] = N_( " [%s] ssys features: '%s'" ),
[HUNK_TYPE_SSYS_FEATURES_REVERT] =
N_( " [%s] ssys features revert: '%s'" ),
[HUNK_TYPE_SPOB_FACTION] = N_( " [%s] spob faction: '%s'" ),
[HUNK_TYPE_SPOB_FACTION_REMOVE] = N_( " [%s] spob faction removal: '%s'" ),
[HUNK_TYPE_SPOB_POPULATION] = N_( " [%s] spob population: '%s'" ),
Expand Down Expand Up @@ -162,11 +169,17 @@ static int diff_cmp( const void *p1, const void *p2 )
*
* @return 0 on success.
*/
int diff_loadAvailable( void )
int diff_init( void )
{
#if DEBUGGING
Uint32 time = SDL_GetTicks();

for ( int i = 0; i < HUNK_TYPE_SENTINAL; i++ ) {
if ( hunk_error[i] == NULL )
WARN( "HUNK_TYPE '%d' missing error message!", i );
}
#endif /* DEBUGGING */

char **diff_files = ndata_listRecursive( UNIDIFF_DATA_PATH );
diff_available =
array_create_size( UniDiffData_t, array_size( diff_files ) );
Expand Down Expand Up @@ -224,6 +237,10 @@ int diff_loadAvailable( void )
return 0;
}

void diff_exit( void )
{
}

/**
* @brief Checks if a diff is currently applied.
*
Expand Down
3 changes: 2 additions & 1 deletion src/unidiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ typedef struct UniHunk_ {
} UniHunk_t;

/* Global functions, manily for player stuff. */
int diff_loadAvailable( void );
int diff_init( void );
void diff_exit( void );
NONNULL( 1 ) int diff_isApplied( const char *name );
NONNULL( 1 ) int diff_apply( const char *name );
NONNULL( 1 ) void diff_remove( const char *name );
Expand Down

0 comments on commit 5dd763e

Please sign in to comment.