/********** list managing methods ***********/

        public bool CheckAndAddReservedSegment(ushort segment_id, ushort reservation_id)
        {
            bool include  = true;
            bool reserved = false;

            for (int i = 0; i < reservedSegments.Count; i++)
            {
                if (reservedSegments[i].segment_id == segment_id)
                {
                    if (reservedSegments[i].reservation_id == 0)
                    {
                        ReservedSegment rs = reservedSegments[i];
                        rs.reservation_id   = reservation_id;
                        reservedSegments[i] = rs;
                        //CODebug.Log(LogChannel.Modding, "changed segment " + segment_id + " for vehicle " + vehicle_id);
                        reserved = true;
                    }
                    include = false;
                    break;
                }
            }

            if (include)
            {
                ReservedSegment rs = new ReservedSegment();
                rs.segment_id     = segment_id;
                rs.reservation_id = reservation_id;
                reservedSegments.Add(rs);
                //CODebug.Log(LogChannel.Modding, "added segment "+ segment_id+ " for vehicle "+ vehicle_id);
                reserved = true;
            }

            return(reserved);
        }
        public void RemoveReservation(ushort reservation_id, bool definitive = true)
        {
            for (int i = 0; i < reservedSegments.Count; i++)
            {
                if (reservedSegments[i].reservation_id == reservation_id)
                {
                    ReservedSegment rs = reservedSegments[i];
                    rs.reservation_id   = 0;
                    reservedSegments[i] = rs;
                }
            }

            if (definitive)
            {
                int r_index = -1;
                for (int i = 0; i < reservations.Count; i++)
                {
                    if (reservations[i].ID == reservation_id)
                    {
                        r_index = i;
                        break;
                    }
                }

                if (r_index == -1)
                {
                    return;
                }

                reservations.RemoveAt(r_index);
            }
        }