Skip to content

Commit fc3c1d1

Browse files
authored
Merge pull request #346 from icosahedral-dragon/fix-cursor-and-damage-crashes
Fix cursor and damage crashes
2 parents 06d882e + 1c46210 commit fc3c1d1

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

src/GameSrc/citres.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ errtype master_load_bitmap_from_res(grs_bitmap *bmp, Id id_num, int i, LGRect *a
7575
return (ERR_FREAD);
7676
}
7777

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

9291
// Copy the bits.
9392
memcount += f->bm.w * f->bm.h; // FIXME is this needed any more?
94-
memcpy(p, f->bm.bits, f->bm.w * f->bm.h);
95-
93+
if (f->bm.type == BMT_RSD8) {
94+
gr_rsd8_convert(&f->bm, bmp);
95+
// gr_rsd8_convert uses its own buffer, so copy it back.
96+
memcpy(p, bmp->bits, f->bm.w * f->bm.h);
97+
} else {
98+
memcpy(p, f->bm.bits, f->bm.w * f->bm.h);
99+
}
96100
bmp->bits = p;
97101

98102
return (OK);

src/GameSrc/damage.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,15 @@ int compute_damage(ObjID target, int damage_type, int damage_mod, ubyte offense,
951951
*effect = effect_matrix[NON_CRITTER_EFFECT][attack_effect_type][0];
952952
} else if (effect != NULL)
953953
*effect = 0;
954-
} else {
954+
} else if (attack_effect_type != SPECIAL_TYPE) {
955955
// we didn't affect - so do the no effect one!
956956
if (effect)
957957
*effect = (!global_fullmap->cyber) ? effect_matrix[NON_CRITTER_EFFECT][attack_effect_type][0] : 0;
958+
} else {
959+
// Special damage type with no damage = no effect.
960+
if (effect) {
961+
*effect = 0;
962+
}
958963
}
959964

960965
return (damage);

src/GameSrc/grenades.c

-17
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
5959
// Internal Prototypes
6060
//----------------
6161
void convert_grenade_to_explosion(ExplosionData *edata, int triple);
62-
ubyte grenade_compute_damage(ObjID target, int wpn_triple, int power_level, ubyte *effect);
6362
ObjID explosion_ray_cast_attack(ObjID gren_id, ObjID target, ObjLoc *gren_loc, fix radius, fix mass, fix speed);
6463
void do_object_explosion(ObjID id);
6564
uchar activate_grenade_on_cursor(void);
@@ -102,22 +101,6 @@ void convert_grenade_to_explosion(ExplosionData *edata, int triple) {
102101
edata->penet = GrenadeProps[ctrip].penetration;
103102
}
104103

105-
// ----------------------------------------------------------------------
106-
// grenade_compute_damage()
107-
//
108-
109-
ubyte grenade_compute_damage(ObjID target, int wpn_triple, int power_level, ubyte *effect) {
110-
ubyte effect_class =
111-
(objs[target].obclass == CLASS_CRITTER) ? CritterProps[CPNUM(target)].hit_effect : NON_CRITTER_EFFECT;
112-
113-
*effect = effect_matrix[effect_class][GREN_TYPE][0];
114-
115-
return (compute_damage(target, GrenadeProps[CPTRIP(wpn_triple)].damage_type,
116-
GrenadeProps[CPTRIP(wpn_triple)].damage_modifier,
117-
GrenadeProps[CPTRIP(wpn_triple)].offense_value, GrenadeProps[CPTRIP(wpn_triple)].penetration,
118-
power_level, NULL, NULL, GREN_TYPE));
119-
}
120-
121104
extern ObjID terrain_hit_exclusion;
122105

123106
// ----------------------------------------------------------------------

0 commit comments

Comments
 (0)