Skip to content

Commit

Permalink
Merge pull request #346 from icosahedral-dragon/fix-cursor-and-damage…
Browse files Browse the repository at this point in the history
…-crashes

Fix cursor and damage crashes
  • Loading branch information
Interrupt committed Jan 9, 2020
2 parents 06d882e + 1c46210 commit fc3c1d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
10 changes: 7 additions & 3 deletions src/GameSrc/citres.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ errtype master_load_bitmap_from_res(grs_bitmap *bmp, Id id_num, int i, LGRect *a
return (ERR_FREAD);
}

const size_t size = f->bm.w * f->bm.h;
if (p == NULL) {
// Caller wants us to allocate a framebuffer.
p = malloc(f->bm.w * f->bm.h);
Expand All @@ -91,8 +90,13 @@ errtype master_load_bitmap_from_res(grs_bitmap *bmp, Id id_num, int i, LGRect *a

// Copy the bits.
memcount += f->bm.w * f->bm.h; // FIXME is this needed any more?
memcpy(p, f->bm.bits, f->bm.w * f->bm.h);

if (f->bm.type == BMT_RSD8) {
gr_rsd8_convert(&f->bm, bmp);
// gr_rsd8_convert uses its own buffer, so copy it back.
memcpy(p, bmp->bits, f->bm.w * f->bm.h);
} else {
memcpy(p, f->bm.bits, f->bm.w * f->bm.h);
}
bmp->bits = p;

return (OK);
Expand Down
7 changes: 6 additions & 1 deletion src/GameSrc/damage.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,15 @@ int compute_damage(ObjID target, int damage_type, int damage_mod, ubyte offense,
*effect = effect_matrix[NON_CRITTER_EFFECT][attack_effect_type][0];
} else if (effect != NULL)
*effect = 0;
} else {
} else if (attack_effect_type != SPECIAL_TYPE) {
// we didn't affect - so do the no effect one!
if (effect)
*effect = (!global_fullmap->cyber) ? effect_matrix[NON_CRITTER_EFFECT][attack_effect_type][0] : 0;
} else {
// Special damage type with no damage = no effect.
if (effect) {
*effect = 0;
}
}

return (damage);
Expand Down
17 changes: 0 additions & 17 deletions src/GameSrc/grenades.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Internal Prototypes
//----------------
void convert_grenade_to_explosion(ExplosionData *edata, int triple);
ubyte grenade_compute_damage(ObjID target, int wpn_triple, int power_level, ubyte *effect);
ObjID explosion_ray_cast_attack(ObjID gren_id, ObjID target, ObjLoc *gren_loc, fix radius, fix mass, fix speed);
void do_object_explosion(ObjID id);
uchar activate_grenade_on_cursor(void);
Expand Down Expand Up @@ -102,22 +101,6 @@ void convert_grenade_to_explosion(ExplosionData *edata, int triple) {
edata->penet = GrenadeProps[ctrip].penetration;
}

// ----------------------------------------------------------------------
// grenade_compute_damage()
//

ubyte grenade_compute_damage(ObjID target, int wpn_triple, int power_level, ubyte *effect) {
ubyte effect_class =
(objs[target].obclass == CLASS_CRITTER) ? CritterProps[CPNUM(target)].hit_effect : NON_CRITTER_EFFECT;

*effect = effect_matrix[effect_class][GREN_TYPE][0];

return (compute_damage(target, GrenadeProps[CPTRIP(wpn_triple)].damage_type,
GrenadeProps[CPTRIP(wpn_triple)].damage_modifier,
GrenadeProps[CPTRIP(wpn_triple)].offense_value, GrenadeProps[CPTRIP(wpn_triple)].penetration,
power_level, NULL, NULL, GREN_TYPE));
}

extern ObjID terrain_hit_exclusion;

// ----------------------------------------------------------------------
Expand Down

0 comments on commit fc3c1d1

Please sign in to comment.