Skip to content

Commit 4a4486c

Browse files
committed
Merge branch 'master' into kill_ship_model_start
2 parents 3eb47c1 + 768e097 commit 4a4486c

25 files changed

+474
-323
lines changed

code/ai/aicode.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13812,18 +13812,22 @@ int ai_await_repair_frame(object *objp, ai_info *aip)
1381213812
// Maybe should only do this if they are preventing their wing from re-entering.
1381313813
void ai_maybe_self_destruct(object *objp, ai_info *aip)
1381413814
{
13815+
Assertion(objp->type == OBJ_SHIP, "ai_maybe_self_destruct() can only be called with objects that are ships!");
13816+
ship *shipp = &Ships[objp->instance];
13817+
1381513818
// Some IFFs can be repaired, so no self-destruct.
1381613819
// In multiplayer, just don't self-destruct. I figured there would be a problem. -- MK, 3/19/98.
13817-
if ((Iff_info[Ships[objp->instance].team].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
13820+
if ((Iff_info[shipp->team].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
1381813821
return;
1381913822

1382013823
// Small ships in a wing blow themselves up after awhile if engine or weapons system has been destroyed.
1382113824
// Reason: Don't want them to prevent a re-emergence of the wing.
1382213825
// Note: Don't blow up if not in a wing for two reasons: One, won't affect re-emergence of waves and (1) disable the Dragon
1382313826
// mission would be broken.
13824-
if ((Ship_info[Ships[objp->instance].ship_info_index].flags & SIF_SMALL_SHIP) && (Ships[objp->instance].wingnum != -1)) {
13825-
if ((ship_get_subsystem_strength(&Ships[objp->instance], SUBSYSTEM_ENGINE) <= 0.0f) ||
13826-
(ship_get_subsystem_strength(&Ships[objp->instance], SUBSYSTEM_WEAPONS) <= 0.0f)) {
13827+
// Also, don't blow up the ship if it has a ship flag preventing this - Goober5000
13828+
if ((Ship_info[shipp->ship_info_index].flags & SIF_SMALL_SHIP) && (shipp->wingnum >= 0) && !(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)) {
13829+
if ((ship_get_subsystem_strength(shipp, SUBSYSTEM_ENGINE) <= 0.0f) ||
13830+
(ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS) <= 0.0f)) {
1382713831
if (aip->self_destruct_timestamp < 0)
1382813832
aip->self_destruct_timestamp = timestamp(90 * 1000); // seconds until self-destruct
1382913833
} else {

code/ai/aiturret.cpp

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,56 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
13341334
//model_find_world_point(gpos, gun_pos, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
13351335
model_instance_find_world_point(gpos, gun_pos, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
13361336

1337-
if (use_angles)
1338-
model_instance_find_world_dir(gvec, &tp->turret_norm, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
1339-
else {
1337+
if (use_angles) {
1338+
model_instance_find_world_dir(gvec, &tp->turret_norm, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
1339+
} else if (tp->flags2 & MSS_FLAG2_SHARE_FIRE_DIRECTION) {
1340+
vec3d shared_dir, avg, tmp_pos, tmp_target, enemy_point;
1341+
vm_vec_avg_n(&avg, tp->turret_num_firing_points, tp->turret_firing_point);
1342+
1343+
model_instance_find_world_point(&tmp_pos, &avg, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
1344+
1345+
if (targetp == nullptr) {
1346+
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship number %d is invalid.", ssp->turret_enemy_objnum, ssp->sub_name, ssp->parent_objnum);
1347+
object *lep = &Objects[ssp->turret_enemy_objnum];
1348+
1349+
int best_weapon_tidx = turret_select_best_weapon(ssp, lep);
1350+
1351+
//This turret doesn't have any good weapons
1352+
if (best_weapon_tidx < 0)
1353+
return;
1354+
1355+
weapon_info *wip = get_turret_weapon_wip(&ssp->weapons, best_weapon_tidx);
1356+
1357+
float weapon_system_strength = ship_get_subsystem_strength(&Ships[ssp->parent_objnum], SUBSYSTEM_WEAPONS);
1358+
1359+
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags & SSF_NO_SS_TARGETING)) {
1360+
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
1361+
vm_vec_add2(&enemy_point, &ssp->last_aim_enemy_pos);
1362+
} else {
1363+
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
1364+
ai_big_pick_attack_point_turret(lep, ssp, &tmp_pos, &tp->turret_norm, &enemy_point, tp->turret_fov, MIN(wip->max_speed * wip->lifetime, wip->weapon_range));
1365+
}
1366+
else {
1367+
enemy_point = ssp->last_aim_enemy_pos;
1368+
}
1369+
}
1370+
1371+
vec3d target_moving_direction = ssp->last_aim_enemy_vel;
1372+
1373+
//Try to guess where the enemy will be, and store that spot in predicted_enemy_pos
1374+
if (The_mission.ai_profile->flags & AIPF_USE_ADDITIVE_WEAPON_VELOCITY) {
1375+
vm_vec_scale_sub2(&target_moving_direction, &objp->phys_info.vel, wip->vel_inherit_amount);
1376+
}
1377+
1378+
set_predicted_enemy_pos_turret(&tmp_target, &tmp_pos, objp, &enemy_point, &target_moving_direction, wip->max_speed, ssp->turret_time_enemy_in_range * (weapon_system_strength + 1.0f) / 2.0f);
1379+
} else {
1380+
tmp_target = *targetp;
1381+
}
1382+
1383+
vm_vec_normalized_dir(&shared_dir, &tmp_target, &tmp_pos);
1384+
1385+
model_instance_find_world_dir(gvec, &shared_dir, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
1386+
} else {
13401387
//vector gun_pos2;
13411388
//vm_vec_add(&gun_pos2, gpos, gun_pos);
13421389
vm_vec_normalized_dir(gvec, targetp, gpos);

code/bmpman/bmpman.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bitmap_lookup::bitmap_lookup(int bitmap_num):
123123
Width = be->bm.w;
124124
Height = be->bm.h;
125125

126-
Bitmap_data = (float*)vm_malloc(Width * Height * Num_channels * sizeof(float));
126+
Bitmap_data = (ubyte*)vm_malloc(Width * Height * Num_channels * sizeof(ubyte));
127127

128128
gr_get_bitmap_from_texture((void*)Bitmap_data, bitmap_num);
129129
}
@@ -156,7 +156,7 @@ float bitmap_lookup::get_channel_red(float u, float v)
156156
int x = fl2i(map_texture_address(u) * (Width-1));
157157
int y = fl2i(map_texture_address(v) * (Height-1));
158158

159-
return Bitmap_data[(y*Width + x)*Num_channels];
159+
return i2fl(Bitmap_data[(y*Width + x)*Num_channels]) / 255.0f;
160160
}
161161

162162
float bitmap_lookup::get_channel_green(float u, float v)
@@ -169,7 +169,7 @@ float bitmap_lookup::get_channel_green(float u, float v)
169169
int x = fl2i(map_texture_address(u) * (Width-1));
170170
int y = fl2i(map_texture_address(v) * (Height-1));
171171

172-
return Bitmap_data[(y*Width + x)*Num_channels + 1];
172+
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 1]) / 255.0f;
173173
}
174174

175175
float bitmap_lookup::get_channel_blue(float u, float v)
@@ -179,7 +179,7 @@ float bitmap_lookup::get_channel_blue(float u, float v)
179179
int x = fl2i(map_texture_address(u) * (Width-1));
180180
int y = fl2i(map_texture_address(v) * (Height-1));
181181

182-
return Bitmap_data[(y*Width + x)*Num_channels + 2];
182+
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 2]) / 255.0f;
183183
}
184184

185185
float bitmap_lookup::get_channel_alpha(float u, float v)
@@ -189,7 +189,7 @@ float bitmap_lookup::get_channel_alpha(float u, float v)
189189
int x = fl2i(map_texture_address(u) * (Width-1));
190190
int y = fl2i(map_texture_address(v) * (Height-1));
191191

192-
return Bitmap_data[(y*Width + x)*Num_channels + 3];
192+
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 3]) / 255.0f;
193193
}
194194

195195
/**

code/bmpman/bmpman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void *bm_malloc(int handle, int size);
175175
void bm_update_memory_used(int n, int size);
176176

177177
class bitmap_lookup {
178-
float *Bitmap_data;
178+
ubyte *Bitmap_data;
179179

180180
int Width;
181181
int Height;

code/cmdline/cmdline.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ Flag exe_params[] =
148148
{ "-enable_shadows", "Enable Shadows", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_shadows"},
149149
{ "-img2dds", "Compress non-compressed images", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-img2dds", },
150150
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
151-
{ "-no_fps_capping", "Don't limit frames-per-second", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_fps_capping", },
152151
{ "-cache_bitmaps", "Cache bitmaps between missions", true, 0, EASY_DEFAULT_MEM, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-cache_bitmaps", },
153152

154153
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },

code/fred2/eventeditor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ void event_editor::OnButtonNewEvent()
672672
return;
673673
}
674674

675+
// before we do anything, we must check and save off any data from the current event (e.g
676+
// the repeat count and interval count)
677+
save();
678+
675679
reset_event(m_num_events++, TVI_LAST);
676680
}
677681

@@ -685,6 +689,11 @@ void event_editor::OnInsert()
685689
return;
686690
}
687691

692+
// before we do anything, we must check and save off any data from the current event (e.g
693+
// the repeat count and interval count)
694+
save();
695+
696+
688697
if(cur_event < 0 || m_num_events == 0)
689698
{
690699
//There are no events yet, so just create one
@@ -750,6 +759,8 @@ void event_editor::reset_event(int num, HTREEITEM after)
750759
m_event_tree.item_index = index;
751760
m_event_tree.add_operator("do-nothing");
752761

762+
update_cur_event();
763+
753764
m_event_tree.SelectItem(h);
754765
// GetDlgItem(IDC_CHAIN_DELAY) -> EnableWindow(FALSE);
755766
if (num >= MAX_MISSION_EVENTS){

0 commit comments

Comments
 (0)