Skip to content

Commit 9622cda

Browse files
committed
prop sexps
1 parent acffb23 commit 9622cda

File tree

13 files changed

+473
-10
lines changed

13 files changed

+473
-10
lines changed

code/parse/sexp.cpp

Lines changed: 283 additions & 0 deletions
Large diffs are not rendered by default.

code/parse/sexp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum sexp_opf_t : int {
3838
OPF_BOOL,
3939
OPF_NUMBER,
4040
OPF_SHIP,
41+
OPF_PROP,
4142
OPF_WING,
4243
OPF_SUBSYSTEM,
4344
OPF_POINT, // either a 3d point in space, or a waypoint name
@@ -66,6 +67,7 @@ enum sexp_opf_t : int {
6667
OPF_MEDAL_NAME, // name of medals
6768
OPF_WEAPON_NAME, // name of a weapon
6869
OPF_SHIP_CLASS_NAME, // name of a ship class
70+
OPF_PROP_CLASS_NAME, // name of a prop class
6971
OPF_CUSTOM_HUD_GAUGE, // name of custom HUD gauge
7072
OPF_HUGE_WEAPON, // name of a secondary bomb type weapon
7173
OPF_SHIP_NOT_PLAYER, // a ship, but not a player ship
@@ -594,6 +596,7 @@ enum : int {
594596
OP_CARGO_NO_DEPLETE,
595597
OP_SET_SPECIAL_WARPOUT_NAME,
596598
OP_SHIP_VANISH,
599+
OP_PROP_VANISH, // MjnMixael
597600
OP_SHIELDS_ON, //-Sesquipedalian
598601
OP_SHIELDS_OFF, //-Sesquipedalian
599602

@@ -692,6 +695,7 @@ enum : int {
692695
OP_SHIP_SUBSYS_GUARDIAN_THRESHOLD, // Goober5000
693696
OP_SET_SKYBOX_MODEL, // taylor
694697
OP_SHIP_CREATE,
698+
OP_PROP_CREATE, // MjnMixael
695699
OP_WEAPON_CREATE, // Goober5000
696700
OP_SET_OBJECT_SPEED_X, // Deprecated by wookieejedi
697701
OP_SET_OBJECT_SPEED_Y, // Deprecated by wookieejedi
@@ -817,6 +821,7 @@ enum : int {
817821
OP_ADD_TO_COLGROUP, // The E
818822
OP_REMOVE_FROM_COLGROUP, // The E
819823
OP_GET_COLGROUP_ID, // The E
824+
OP_GET_COLGROUP_ID_PROP, // MjnMixael
820825
OP_SHIP_EFFECT, // Valathil
821826
OP_CLEAR_SUBTITLES, // The E
822827
OP_BEAM_FIRE_COORDS, // Goober5000
@@ -873,6 +878,8 @@ enum : int {
873878
OP_SET_TRAITOR_OVERRIDE, //MjnMixael
874879
OP_ADD_TO_COLGROUP_NEW, // Goober5000
875880
OP_REMOVE_FROM_COLGROUP_NEW, // Goober5000
881+
OP_ADD_TO_COLGROUP_PROP, // MjnMixael
882+
OP_REMOVE_FROM_COLGROUP_PROP, // MjnMixael
876883
OP_GET_POWER_OUTPUT, // The E
877884
OP_TURRET_SET_FORCED_TARGET, // Asteroth
878885
OP_TURRET_SET_FORCED_SUBSYS_TARGET, // Asteroth
@@ -1183,6 +1190,7 @@ enum sexp_error_check
11831190

11841191
SEXP_CHECK_INVALID_NUM = 101, // number is not valid
11851192
SEXP_CHECK_INVALID_SHIP, // invalid ship name
1193+
SEXP_CHECK_INVALID_PROP, // invalid prop name
11861194
SEXP_CHECK_INVALID_WING, // invalid wing name
11871195
SEXP_CHECK_INVALID_SUBSYS, // invalid subsystem
11881196
SEXP_CHECK_INVALID_IFF, // invalid iff string

code/prop/prop.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ static SCP_vector<SCP_string> Removed_props;
1717
/**
1818
* Return the index of Prop_info[].name that is *token.
1919
*/
20-
static int prop_info_lookup_sub(const char* token)
20+
int prop_info_lookup(const char* token)
2121
{
22-
Assertion(token != nullptr, "NULL token passed to prop_info_lookup_sub");
22+
Assertion(token != nullptr, "NULL token passed to prop_info_lookup");
2323

2424
for (auto it = Prop_info.cbegin(); it != Prop_info.cend(); ++it)
2525
if (!stricmp(token, it->name))
@@ -88,7 +88,7 @@ void parse_prop_table(const char* filename)
8888
}
8989

9090
// Check if prop exists already
91-
int prop_id = prop_info_lookup_sub(fname);
91+
int prop_id = prop_info_lookup(fname);
9292

9393
// maybe remove it
9494
if (remove_prop) {
@@ -416,7 +416,7 @@ void prop_render(object* obj, model_draw_list* scene)
416416

417417
void spawn_test_prop()
418418
{
419-
int prop_idx = prop_info_lookup_sub("TestProp"); // whatever’s in your props.tbl
419+
int prop_idx = prop_info_lookup("TestProp"); // whatever’s in your props.tbl
420420
if (prop_idx < 0) {
421421
mprintf(("TEST: Prop not found!\n"));
422422
return;

code/prop/prop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ void prop_render(object* obj, model_draw_list* scene);
5656

5757
void props_level_close();
5858

59+
int prop_info_lookup(const char* token);
60+
int prop_name_lookup(const char* name);
61+
5962
void spawn_test_prop();

code/prop/prop_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FLAG_LIST(Prop_Flags){
2424
FLAG_LIST(Info_Flags){
2525
No_collide = 0, // No collisions
2626
No_fred, // not available in fred
27-
No_impact_debris, // wookieejedi - Don't spawn the small debris on impact
27+
//No_impact_debris,
2828
No_lighting,
2929

3030
NUM_VALUES};

fred2/mainfrm.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,11 @@ void color_combo_box_prop::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
494494
if (pip != nullptr) {
495495
strText = _T(pip->name);
496496
} else {
497-
strText = _T("Invalid index!");
497+
if (prop_type_combo_box_size == 0) {
498+
strText = _T("No props available");
499+
} else {
500+
strText = _T("Invalid index!");
501+
}
498502
}
499503

500504
pDC->ExtTextOut(lpDrawItemStruct->rcItem.left,

fred2/mainfrm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
class color_combo_box_prop : public CComboBox {
1717
public:
1818
/**
19-
* Gets the ship class corresponding to the item index
19+
* Gets the prop class corresponding to the item index
2020
*/
2121
int GetPropClass(int item_index);
2222

2323
/**
24-
* Gets the item index corresponding to the ship class
24+
* Gets the item index corresponding to the prop class
2525
*/
26-
int GetItemIndex(int ship_class);
26+
int GetItemIndex(int prop_class);
2727

2828
private:
2929
/**

fred2/sexp_tree.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "nebula/neb.h"
3737
#include "nebula/neblightning.h"
3838
#include "jumpnode/jumpnode.h"
39+
#include "prop/prop.h"
3940
#include "AddVariableDlg.h"
4041
#include "ModifyVariableDlg.h"
4142
#include "gamesnd/eventmusic.h" // for change-soundtrack
@@ -3318,6 +3319,10 @@ int sexp_tree::get_default_value(sexp_list_item *item, char *text_buf, int op, i
33183319
str = "<name of ship here>";
33193320
break;
33203321

3322+
case OPF_PROP:
3323+
str = "<name of prop here>";
3324+
break;
3325+
33213326
case OPF_ORDER_RECIPIENT:
33223327
str = "<all fighters>";
33233328
break;
@@ -3494,6 +3499,7 @@ int sexp_tree::query_default_argument_available(int op, int i)
34943499
case OPF_WEAPON_NAME:
34953500
case OPF_INTEL_NAME:
34963501
case OPF_SHIP_CLASS_NAME:
3502+
case OPF_PROP_CLASS_NAME:
34973503
case OPF_HUGE_WEAPON:
34983504
case OPF_JUMP_NODE_NAME:
34993505
case OPF_AMBIGUOUS:
@@ -3570,6 +3576,16 @@ int sexp_tree::query_default_argument_available(int op, int i)
35703576

35713577
return 0;
35723578

3579+
case OPF_PROP:
3580+
ptr = GET_FIRST(&obj_used_list);
3581+
while (ptr != END_OF_LIST(&obj_used_list)) {
3582+
if (ptr->type == OBJ_PROP)
3583+
return 1;
3584+
3585+
ptr = GET_NEXT(ptr);
3586+
}
3587+
return 0;
3588+
35733589
case OPF_SHIP_NOT_PLAYER:
35743590
case OPF_ORDER_RECIPIENT:
35753591
ptr = GET_FIRST(&obj_used_list);
@@ -5396,6 +5412,10 @@ sexp_list_item *sexp_tree::get_listing_opf(int opf, int parent_node, int arg_ind
53965412
list = get_listing_opf_ship(parent_node);
53975413
break;
53985414

5415+
case OPF_PROP:
5416+
list = get_listing_opf_prop(parent_node);
5417+
break;
5418+
53995419
case OPF_WING:
54005420
list = get_listing_opf_wing();
54015421
break;
@@ -5567,6 +5587,10 @@ sexp_list_item *sexp_tree::get_listing_opf(int opf, int parent_node, int arg_ind
55675587
list = get_listing_opf_ship_class_name();
55685588
break;
55695589

5590+
case OPF_PROP_CLASS_NAME:
5591+
list = get_listing_opf_prop_class_name();
5592+
break;
5593+
55705594
case OPF_HUGE_WEAPON:
55715595
list = get_listing_opf_huge_weapon();
55725596
break;
@@ -6129,6 +6153,23 @@ sexp_list_item *sexp_tree::get_listing_opf_ship(int parent_node)
61296153
return head.next;
61306154
}
61316155

6156+
sexp_list_item *sexp_tree::get_listing_opf_prop(int parent_node)
6157+
{
6158+
object *ptr;
6159+
sexp_list_item head;
6160+
6161+
ptr = GET_FIRST(&obj_used_list);
6162+
while (ptr != END_OF_LIST(&obj_used_list)) {
6163+
if (ptr->type == OBJ_PROP) {
6164+
head.add_data(Props[ptr->instance].prop_name);
6165+
}
6166+
6167+
ptr = GET_NEXT(ptr);
6168+
}
6169+
6170+
return head.next;
6171+
}
6172+
61326173
sexp_list_item *sexp_tree::get_listing_opf_wing()
61336174
{
61346175
int i;
@@ -7225,6 +7266,16 @@ sexp_list_item *sexp_tree::get_listing_opf_ship_class_name()
72257266
return head.next;
72267267
}
72277268

7269+
sexp_list_item* sexp_tree::get_listing_opf_prop_class_name()
7270+
{
7271+
sexp_list_item head;
7272+
7273+
for (auto& pi : Prop_info)
7274+
head.add_data(pi.name);
7275+
7276+
return head.next;
7277+
}
7278+
72287279
sexp_list_item *sexp_tree::get_listing_opf_huge_weapon()
72297280
{
72307281
sexp_list_item head;

fred2/sexp_tree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class sexp_tree : public CTreeCtrl
220220
sexp_list_item *get_listing_opf_positive();
221221
sexp_list_item *get_listing_opf_number();
222222
sexp_list_item *get_listing_opf_ship(int parent_node = -1);
223+
sexp_list_item *get_listing_opf_prop(int parent_node = -1);
223224
sexp_list_item *get_listing_opf_wing();
224225
sexp_list_item *get_listing_opf_subsystem(int parent_node, int arg_index);
225226
sexp_list_item *get_listing_opf_subsystem_type(int parent_node);
@@ -249,6 +250,7 @@ class sexp_tree : public CTreeCtrl
249250
sexp_list_item *get_listing_opf_medal_name();
250251
sexp_list_item *get_listing_opf_weapon_name();
251252
sexp_list_item *get_listing_opf_ship_class_name();
253+
sexp_list_item *get_listing_opf_prop_class_name();
252254
sexp_list_item *get_listing_opf_huge_weapon();
253255
sexp_list_item *get_listing_opf_ship_not_player();
254256
sexp_list_item *get_listing_opf_jump_nodes();

qtfred/src/mission/missionsave.cpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <starfield/nebula.h>
4040
#include <starfield/starfield.h>
4141
#include <weapon/weapon.h>
42+
#include <prop/prop.h>
4243

4344
#include "missionsave.h"
4445
#include "util.h"
@@ -3146,6 +3147,8 @@ void CFred_mission_save::save_mission_internal(const char* pathname)
31463147
err = -7;
31473148
} else if (save_wings()) {
31483149
err = -8;
3150+
} else if (save_props()) {
3151+
err = -18;
31493152
} else if (save_events()) {
31503153
err = -9;
31513154
} else if (save_goals()) {
@@ -5131,7 +5134,7 @@ int CFred_mission_save::save_wings()
51315134
}
51325135

51335136
count++;
5134-
required_string_either_fred("$Name:", "#Events");
5137+
required_string_one_of_fred(3, "$Name:", "#Events", "#Props");
51355138
required_string_fred("$Name:");
51365139
parse_comments(2);
51375140
fout(" %s", Wings[i].name);
@@ -5407,5 +5410,50 @@ int CFred_mission_save::save_wings()
54075410
return err;
54085411
}
54095412

5413+
int CFred_mission_save::save_props()
5414+
{
5415+
if (save_format != MissionFormat::RETAIL) {
5416+
fred_parse_flag = 0;
5417+
required_string_fred("#Props");
5418+
parse_comments(2);
5419+
fout("\t\t;! %d total", static_cast<int>(Props.size()));
5420+
5421+
for (int i = 0; i < static_cast<int>(Props.size()); i++) {
5422+
required_string_either_fred("$Name:", "#Events");
5423+
required_string_fred("$Name:");
5424+
parse_comments(2);
5425+
fout(" %s", Props[i].prop_name);
5426+
5427+
required_string_fred("$Class:");
5428+
parse_comments(2);
5429+
fout(" %d", Props[i].prop_info_index);
5430+
5431+
required_string_fred("$Location:");
5432+
parse_comments();
5433+
save_vector(Objects[Props[i].objnum].pos);
5434+
5435+
required_string_fred("$Orientation:");
5436+
parse_comments();
5437+
save_matrix(Objects[Props[i].objnum].orient);
5438+
5439+
if (optional_string_fred("+Flags:", "$Name:")) {
5440+
parse_comments();
5441+
fout(" (");
5442+
} else
5443+
fout("\n+Flags: (");
5444+
5445+
if (!(Objects[Props[i].objnum].flags[Object::Object_Flags::Collides]))
5446+
fout(" \"no_collide\"");
5447+
fout(" )");
5448+
5449+
fso_comment_pop();
5450+
}
5451+
}
5452+
5453+
fso_comment_pop(true);
5454+
// Assert(count == Num_props);
5455+
return err;
5456+
}
5457+
54105458
}
54115459
}

0 commit comments

Comments
 (0)