File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -881,7 +881,16 @@ t_pack_molecule *alloc_and_load_pack_molecules(
881
881
/* try_pack_molecule function can pack more than one atom */
882
882
/* check if we packed last atom of a chain */
883
883
int num_blocks = cur_molecule->num_blocks ;
884
- auto last_block = cur_molecule->atom_block_ids [num_blocks-1 ];
884
+
885
+ /* Getting the last valid block of a molecule */
886
+ auto last_block = AtomBlockId::INVALID ();
887
+ for (int i = 0 ; i < num_blocks; i++) {
888
+ auto tmp_last_block = cur_molecule->atom_block_ids [i];
889
+ if (tmp_last_block != AtomBlockId::INVALID ())
890
+ last_block = tmp_last_block;
891
+ else
892
+ break ;
893
+ }
885
894
886
895
/* Getting the next blk_id in the chain. If there is not the chain is completed */
887
896
blk_id = AtomBlockId::INVALID ();
You can’t perform that action at this time.
0 commit comments