From 51e9970c38380a3e5938c0e13a272f6b4bac481d Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Mon, 25 Nov 2024 15:20:10 -0500 Subject: [PATCH] [bug] fix mcx crash when replay is requested without seed file --- src/mcx_utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mcx_utils.c b/src/mcx_utils.c index 699612f9..26372639 100644 --- a/src/mcx_utils.c +++ b/src/mcx_utils.c @@ -1493,6 +1493,11 @@ void mcx_preprocess(Config* cfg) { cfg->issavedet = 0; } + if ((cfg->outputtype == otJacobian || cfg->outputtype == otWP || cfg->outputtype == otDCS || cfg->outputtype == otRF) + && cfg->seed != SEED_FROM_FILE) { + MCX_ERROR(-6, "Jacobian output is only valid in the reply mode. Please define cfg.seed"); + } + // if neither trajectory or polarization is enabled, disable istrajstokes flag if (!(cfg->debuglevel & (MCX_DEBUG_MOVE | MCX_DEBUG_MOVE_ONLY)) || !((cfg->mediabyte <= 4) && (cfg->polmedianum > 0))) { cfg->istrajstokes = 0; @@ -2852,7 +2857,7 @@ int mcx_loadjson(cJSON* root, Config* cfg) { MCX_ERROR(-1, "Optode.Source.Pattern JData-annotated array must be in the 'single' format"); } - if (ndim == 3 && dims[2] > 1 && dims[0] > 1 && cfg->srctype == MCX_SRC_PATTERN || cfg->srctype == MCX_SRC_PATTERN3D) { + if (ndim == 3 && dims[2] > 1 && dims[0] > 1 && (cfg->srctype == MCX_SRC_PATTERN || cfg->srctype == MCX_SRC_PATTERN3D)) { cfg->srcnum = dims[0]; } } else { @@ -3766,11 +3771,6 @@ void mcx_validatecfg(Config* cfg, float* detps, int dimdetps[2], int seedbyte) { cfg->seed = time(NULL); } - if ((cfg->outputtype == otJacobian || cfg->outputtype == otWP || cfg->outputtype == otDCS || cfg->outputtype == otRF) - && cfg->seed != SEED_FROM_FILE) { - MCX_ERROR(-6, "Jacobian output is only valid in the reply mode. Please define cfg.seed"); - } - for (i = 0; i < cfg->detnum; i++) { if (!cfg->issrcfrom0) { cfg->detpos[i].x--;