mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Don't try to force depth to be unsigned
Trying to clean up the signed vs. unsigned issues it becomes clear that forcing depth to be unsigned causes way too many problems in the code. So this commit goes the opposite direction; since we clearly aren't limited INT_MAX vs UINT_MAX, simply make more of the depth related variables signed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e93c99c8bc
commit
22c94a3e65
5 changed files with 19 additions and 18 deletions
|
@ -36,7 +36,7 @@ extern pressure_t first_ceiling_pressure;
|
|||
struct buehlmann_config {
|
||||
double satmult; //! safety at inert gas accumulation as percentage of effect (more than 100).
|
||||
double desatmult; //! safety at inert gas depletion as percentage of effect (less than 100).
|
||||
unsigned int last_deco_stop_in_mtr; //! depth of last_deco_stop.
|
||||
int last_deco_stop_in_mtr; //! depth of last_deco_stop.
|
||||
double gf_high; //! gradient factor high (at surface).
|
||||
double gf_low; //! gradient factor low (at bottom/start of deco calculation).
|
||||
double gf_low_position_min; //! gf_low_position below surface_min_shallow.
|
||||
|
@ -572,9 +572,9 @@ void restore_deco_state(char *data)
|
|||
memcpy(&ci_pointing_to_guiding_tissue, data, sizeof(int));
|
||||
}
|
||||
|
||||
unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth)
|
||||
int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth)
|
||||
{
|
||||
unsigned int depth;
|
||||
int depth;
|
||||
double pressure_delta;
|
||||
|
||||
/* Avoid negative depths */
|
||||
|
|
|
@ -11,6 +11,7 @@ extern double tissue_inertgas_saturation[16];
|
|||
extern double buehlmann_inertgas_a[16], buehlmann_inertgas_b[16];
|
||||
extern double gf_low_pressure_this_dive;
|
||||
|
||||
extern int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -3252,7 +3252,7 @@ void set_informational_units(char *units)
|
|||
}
|
||||
}
|
||||
|
||||
void average_max_depth(struct diveplan *dive, unsigned int *avg_depth, unsigned int *max_depth)
|
||||
void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth)
|
||||
{
|
||||
int integral = 0;
|
||||
int last_time = 0;
|
||||
|
|
|
@ -793,7 +793,6 @@ extern void subsurface_command_line_exit(int *, char ***);
|
|||
extern void add_segment(double pressure, const struct gasmix *gasmix, int period_in_seconds, int setpoint, const struct dive *dive, int sac);
|
||||
extern void clear_deco(double surface_pressure);
|
||||
extern void dump_tissues(void);
|
||||
extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
|
||||
extern void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth);
|
||||
extern void cache_deco_state(char **datap);
|
||||
extern void restore_deco_state(char *data);
|
||||
|
@ -805,7 +804,7 @@ extern double tissue_tolerance_calc(const struct dive *dive, double pressure);
|
|||
/* this should be converted to use our types */
|
||||
struct divedatapoint {
|
||||
int time;
|
||||
unsigned int depth;
|
||||
int depth;
|
||||
struct gasmix gasmix;
|
||||
int setpoint;
|
||||
bool entered;
|
||||
|
@ -893,7 +892,7 @@ extern depth_t string_to_depth(const char *str);
|
|||
extern pressure_t string_to_pressure(const char *str);
|
||||
extern volume_t string_to_volume(const char *str, pressure_t workp);
|
||||
extern fraction_t string_to_fraction(const char *str);
|
||||
extern void average_max_depth(struct diveplan *dive, unsigned int *avg_depth, unsigned int *max_depth);
|
||||
extern void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth);
|
||||
|
||||
#include "pref.h"
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "dive.h"
|
||||
#include "deco.h"
|
||||
#include "divelist.h"
|
||||
#include "planner.h"
|
||||
#include "gettext.h"
|
||||
|
@ -103,7 +104,7 @@ int get_gasidx(struct dive *dive, struct gasmix *mix)
|
|||
|
||||
void interpolate_transition(struct dive *dive, duration_t t0, duration_t t1, depth_t d0, depth_t d1, const struct gasmix *gasmix, o2pressure_t po2)
|
||||
{
|
||||
int j;
|
||||
uint32_t j;
|
||||
|
||||
for (j = t0.seconds; j < t1.seconds; j++) {
|
||||
int depth = interpolate(d0.mm, d1.mm, j - t0.seconds, t1.seconds - t0.seconds);
|
||||
|
@ -476,11 +477,11 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, int *gascha
|
|||
}
|
||||
|
||||
/* sort all the stops into one ordered list */
|
||||
static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr)
|
||||
static int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr)
|
||||
{
|
||||
int i, gi, di;
|
||||
int total = dnr + gnr;
|
||||
unsigned int *stoplevels = malloc(total * sizeof(int));
|
||||
int *stoplevels = malloc(total * sizeof(int));
|
||||
|
||||
/* no gaschanges */
|
||||
if (gnr == 0) {
|
||||
|
@ -981,13 +982,13 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
int po2;
|
||||
int transitiontime, gi;
|
||||
int current_cylinder;
|
||||
unsigned int stopidx;
|
||||
int stopidx;
|
||||
int depth;
|
||||
struct gaschanges *gaschanges = NULL;
|
||||
int gaschangenr;
|
||||
int *decostoplevels;
|
||||
int decostoplevelcount;
|
||||
unsigned int *stoplevels = NULL;
|
||||
int *stoplevels = NULL;
|
||||
bool stopping = false;
|
||||
bool pendinggaschange = false;
|
||||
int clock, previous_point_time;
|
||||
|
|
Loading…
Reference in a new issue