Address UB warnings found by the static analyzer

This commit is contained in:
2024-08-10 11:56:51 -04:00
parent a52ce5189b
commit a202918d57
4 changed files with 6 additions and 6 deletions

View File

@@ -2744,7 +2744,7 @@ location get_cur_direction(location the_point) {
static eDirection find_waterfall(short x, short y, short mode){
// If more than one waterfall adjacent, randomly selects
bool to_dir[8];
std::bitset<8> to_dir;
for(eDirection i = DIR_N; i < DIR_HERE; i++){
if(mode == 0){
eTerSpec spec = univ.scenario.ter_types[univ.town->terrain(x + dir_x_dif[i],y + dir_y_dif[i])].special;
@@ -2757,7 +2757,7 @@ static eDirection find_waterfall(short x, short y, short mode){
}
}
short count = 0;
for(int i = 0; i < 8; i++)
for(int i = DIR_N; i < DIR_HERE; i++)
count += to_dir[i];
if(count > 0) count = get_ran(1,1,count);
else return DIR_HERE;

View File

@@ -1023,7 +1023,7 @@ void do_combat_cast(location target) {
CLOUD_STINK,CLOUD_STINK,
WALL_ICE,WALL_ICE,WALL_BLADES,
};
mon_num_t summon;
mon_num_t summon = 0;
iLiving* victim;
cPlayer& caster = univ.current_pc();
bool allow_obstructed = false, allow_antimagic = false;

View File

@@ -3554,7 +3554,7 @@ void ifthen_spec(const runtime_state& ctx) {
ctx.next_spec = spec.ex1b;
else if(dynamic_cast<cPlayer*>(&current_pc_picked_in_spec_enc(ctx))) {
int pc = univ.get_target_i(current_pc_picked_in_spec_enc(ctx));
eMainStatus stat;
eMainStatus stat = eMainStatus::ALIVE;
switch(spec.ex1a) {
case 0:
stat = eMainStatus::DEAD;
@@ -4570,7 +4570,7 @@ void handle_message(const runtime_state& ctx, const std::string& title, pic_num_
}
void get_strs(std::string& str1,std::string& str2,eSpecCtxType cur_type,short which_str1,short which_str2) {
size_t num_strs;
size_t num_strs = 0;
if(cur_type == eSpecCtxType::SCEN)
num_strs = univ.scenario.spec_strs.size();
else if(cur_type == eSpecCtxType::OUTDOOR)

View File

@@ -915,7 +915,7 @@ void print_nums(short a,short b,short c) {
}
short print_terrain(location space) {
ter_num_t which_terrain;
ter_num_t which_terrain = 0;
if(overall_mode == MODE_LOOK_OUTDOORS) {
which_terrain = univ.out[space.x][space.y];