View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002330 | FSSCP | SEXPs | public | 2010-10-22 04:27 | 2010-11-04 05:41 |
Reporter | FUBAR-BDHR | Assigned To | FUBAR-BDHR | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.6.13 | ||||
Fixed in Version | 3.6.13 | ||||
Summary | 0002330: ship-subsytem-targetable/untargetable don't work in multi | ||||
Description | Heck with this I'll just post the fix :) | ||||
Additional Information | Note fix requires (and includes) other new sexp code. | ||||
Tags | No tags attached. | ||||
2010-10-22 04:27
|
4subsys_and_untargetablefix.patch (9,556 bytes)
Index: parse/sexp.cpp =================================================================== --- parse/sexp.cpp (revision 6659) +++ parse/sexp.cpp (working copy) @@ -353,6 +353,10 @@ { "ship-targetable-as-bomb", OP_SHIP_BOMB_TARGETABLE, 1, INT_MAX }, { "ship-untargetable-as-bomb", OP_SHIP_BOMB_UNTARGETABLE, 1, INT_MAX }, { "ship-subsys-targetable", OP_SHIP_SUBSYS_TARGETABLE, 2, INT_MAX }, // Goober5000 + { "ship-subsys-no-replace", OP_SHIP_SUBSYS_NO_REPLACE, 3, INT_MAX }, // FUBAR + { "ship-subsys-no-live-debris", OP_SHIP_SUBSYS_NO_LIVE_DEBRIS, 3, INT_MAX }, // FUBAR + { "ship-subsys-vanished", OP_SHIP_SUBSYS_VANISHED, 3, INT_MAX }, // FUBAR + { "ship-subsys-ignore_if_dead", OP_SHIP_SUBSYS_IGNORE_IF_DEAD, 3, INT_MAX }, // FUBAR { "ship-subsys-untargetable", OP_SHIP_SUBSYS_UNTARGETABLE, 2, INT_MAX }, // Goober5000 { "ship-vaporize", OP_SHIP_VAPORIZE, 1, INT_MAX }, // Goober5000 { "ship-no-vaporize", OP_SHIP_NO_VAPORIZE, 1, INT_MAX }, // Goober5000 @@ -11020,7 +11024,6 @@ } } } - // modified by Goober5000; now it should work properly // function to deal with breaking/fixing the warp engines on ships/wings. // --repairable is true when we are breaking the warp drive (can be repaired) @@ -11768,13 +11771,21 @@ { char *subsys; ship_subsys *ss; + ship *shipp = NULL; // get the ship - int ship_num = ship_name_lookup(CTEXT(n)); - if (ship_num < 0) + shipp = sexp_get_ship_from_node(n); + if (shipp == NULL) { return; - n = CDR(n); + } + //multiplayer packet start + multi_start_packet(); + multi_send_int(SSF_UNTARGETABLE); + multi_send_ship(shipp); + multi_send_bool(untargetable ? true : false); + + // get the subsystems for (; n >= 0; n = CDR(n)) { @@ -11783,7 +11794,7 @@ // deal with generic subsystem names int generic_type = get_generic_subsys(subsys); if (generic_type) { - for (ss = GET_FIRST(&Ships[ship_num].subsys_list); ss != END_OF_LIST(&Ships[ship_num].subsys_list); ss = GET_NEXT(ss)) { + for (ss = GET_FIRST(&shipp->subsys_list); ss != END_OF_LIST(&shipp->subsys_list); ss = GET_NEXT(ss)) { if (generic_type == ss->system_info->type) { if (untargetable) ss->flags |= SSF_UNTARGETABLE; @@ -11793,7 +11804,7 @@ } } else { - ss = ship_get_subsys(&Ships[ship_num], subsys); + ss = ship_get_subsys(shipp, subsys); if (ss == NULL) continue; @@ -11802,9 +11813,106 @@ else ss->flags &= ~SSF_UNTARGETABLE; } + // multiplayer send subsystem name + multi_send_string(subsys); } + // mulitplayer end of packet + multi_end_packet(); } +//FUBAR +void sexp_ship_deal_with_subsystem_flag(int node, int ss_flag, bool sendit = false) +{ + ship *shipp = NULL; + ship_subsys *ss = NULL; + + // get ship + shipp = sexp_get_ship_from_node(node); + if (shipp == NULL) { + return; + } + + //replace or not + node = CDR(node); + int setit = is_sexp_true(node); + + //multiplayer packet start + if (sendit) + { + multi_start_packet(); + multi_send_int(ss_flag); + multi_send_ship(shipp); + multi_send_bool(setit ? true : false); + } + + //Process subsystems + while(node != -1) + { + // get the subsystem + ss = ship_get_subsys(shipp, CTEXT(node)); + if(ss == NULL) + { + node = CDR(node); + continue; + } + + // set the flag + if(setit) + ss->flags |= ss_flag; + else + ss->flags &= ~ss_flag; + + // multiplayer send subsystem name + if (sendit) + multi_send_string(CTEXT(node)); + + // next + node = CDR(node); + } + + // mulitplayer end of packet + if (sendit) + multi_end_packet(); +} +void multi_sexp_deal_with_subsys_flag() +{ + int ss_flag = 0; + bool setit = false; + ship_subsys *ss = NULL; + ship *shipp = NULL; + char ss_name[MAX_NAME_LEN]; + + multi_get_int(ss_flag); + multi_get_ship(shipp); + multi_get_bool(setit); + + while (multi_get_string(ss_name)) + { + int generic_type = get_generic_subsys(ss_name); + if (generic_type) { + for (ss = GET_FIRST(&shipp->subsys_list); ss != END_OF_LIST(&shipp->subsys_list); ss = GET_NEXT(ss)) { + if (generic_type == ss->system_info->type) { + if (setit) + ss->flags |= ss_flag; + else + ss->flags &= ~ss_flag; + } + } + } + else + { + ss = ship_get_subsys(shipp, ss_name); + if(ss != NULL) + { + // set the flag + if(setit) + ss->flags |= ss_flag; + else + ss->flags &= ~ss_flag; + } + } + } +} // Goober5000 void sexp_ship_tag( int n, int tag ) { @@ -18308,6 +18416,26 @@ sexp_val = SEXP_TRUE; break; + case OP_SHIP_SUBSYS_NO_REPLACE: + sexp_ship_deal_with_subsystem_flag(node, SSF_NO_REPLACE, true); + sexp_val = SEXP_TRUE; + break; + + case OP_SHIP_SUBSYS_NO_LIVE_DEBRIS: + sexp_ship_deal_with_subsystem_flag(node, SSF_NO_LIVE_DEBRIS, true); + sexp_val = SEXP_TRUE; + break; + + case OP_SHIP_SUBSYS_VANISHED: + sexp_ship_deal_with_subsystem_flag(node, SSF_VANISHED, true); + sexp_val = SEXP_TRUE; + break; + + case OP_SHIP_SUBSYS_IGNORE_IF_DEAD: + sexp_ship_deal_with_subsystem_flag(node, SSF_MISSILES_IGNORE_IF_DEAD, false); + sexp_val = SEXP_TRUE; + break; + case OP_SHIP_CREATE: sexp_ship_create(node); sexp_val = SEXP_TRUE; @@ -19579,6 +19707,15 @@ multi_sexp_change_subsystem_name(); break; + case OP_SHIP_SUBSYS_NO_REPLACE: + case OP_SHIP_SUBSYS_NO_LIVE_DEBRIS: + case OP_SHIP_SUBSYS_VANISHED: + case OP_SHIP_SUBSYS_IGNORE_IF_DEAD: + case OP_SHIP_SUBSYS_TARGETABLE: + case OP_SHIP_SUBSYS_UNTARGETABLE: + multi_sexp_deal_with_subsys_flag(); + break; + case OP_SHIP_CHANGE_CALLSIGN: multi_sexp_ship_change_callsign(); break; @@ -20086,6 +20223,10 @@ case OP_SHIP_UNSTEALTHY: case OP_FRIENDLY_STEALTH_INVISIBLE: case OP_FRIENDLY_STEALTH_VISIBLE: + case OP_SHIP_SUBSYS_NO_REPLACE: + case OP_SHIP_SUBSYS_NO_LIVE_DEBRIS: + case OP_SHIP_SUBSYS_VANISHED: + case OP_SHIP_SUBSYS_IGNORE_IF_DEAD: case OP_SHIP_SUBSYS_TARGETABLE: case OP_SHIP_SUBSYS_UNTARGETABLE: case OP_RED_ALERT: @@ -20481,6 +20622,17 @@ else return OPF_SUBSYS_OR_GENERIC; + case OP_SHIP_SUBSYS_NO_REPLACE: + case OP_SHIP_SUBSYS_NO_LIVE_DEBRIS: + case OP_SHIP_SUBSYS_VANISHED: + case OP_SHIP_SUBSYS_IGNORE_IF_DEAD: + if (argnum == 0) + return OPF_SHIP; + else if (argnum == 1) + return OPF_BOOL; + else + return OPF_SUBSYSTEM; + case OP_IS_DESTROYED: case OP_HAS_ARRIVED: case OP_HAS_DEPARTED: @@ -23045,6 +23197,10 @@ case OP_FRIENDLY_STEALTH_VISIBLE: case OP_SHIP_SUBSYS_TARGETABLE: case OP_SHIP_SUBSYS_UNTARGETABLE: + case OP_SHIP_SUBSYS_NO_REPLACE: + case OP_SHIP_SUBSYS_NO_LIVE_DEBRIS: + case OP_SHIP_SUBSYS_VANISHED: + case OP_SHIP_SUBSYS_IGNORE_IF_DEAD: case OP_WARP_BROKEN: case OP_WARP_NOT_BROKEN: case OP_WARP_NEVER: @@ -24929,6 +25085,41 @@ "\t1:\tName of a ship\r\n" "\tRest: Name of the ship's subsystem(s)" }, + // FUBAR + { OP_SHIP_SUBSYS_NO_REPLACE, "ship-subsys-no-replace\r\n" + "\tCauses the -destroyed version of specified ship subsystem(s) to not render when it's destroyed.\r\n" + "Takes 3 or more arguments...\r\n" + "\t1:\tName of a ship\r\n" + "\t2:\tTrue = Do not render or False = render if exists\r\n" + "\tRest: Name of the ship's subsystem(s)" + "\tNote: If subsystem is already dead it will vanish or reappear out of thin air" }, + + + // FUBAR + { OP_SHIP_SUBSYS_NO_LIVE_DEBRIS, "ship-subsys-no-live-debris\r\n" + "\tCauses the specified ship subsystem(s) to not render live debris when it's destroyed.\r\n" + "Takes 3 or more arguments...\r\n" + "\t1:\tName of a ship\r\n" + "\t2:\tTrue = Do not render or False = render if exists\r\n" + "\tRest: Name of the ship's subsystem(s)" }, + + // FUBAR + { OP_SHIP_SUBSYS_VANISHED, "ship-subsys-vanished\r\n" + "\tCauses the subsystem to vanish without a trace it's destroyed.\r\n" + "Takes 3 or more arguments...\r\n" + "\t1:\tName of a ship\r\n" + "\t2:\tTrue = vanish or False = don't vanish\r\n" + "\tRest: Name of the ship's subsystem(s)" + "\tNote: Useful for replacing subsystems with actual docked models." }, + + // FUBAR + { OP_SHIP_SUBSYS_IGNORE_IF_DEAD, "ship-subsys-ignore-if-dead\r\n" + "\tCauses secondary weapons to ignore dead ship subsystem(s)and home on hull instead.\r\n" + "Takes 3 or more arguments...\r\n" + "\t1:\tName of a ship\r\n" + "\t2:\tTrue = Ignore dead or False = don't ignore\r\n" + "\tRest: Name of the ship's subsystem(s)" }, + // Goober5000 { OP_SHIP_CHANGE_ALT_NAME, "ship-change-alt-name\r\n" "\tChanges the alternate ship class name displayed in the HUD target window. Takes 2 or more arguments...\r\n" Index: parse/sexp.h =================================================================== --- parse/sexp.h (revision 6659) +++ parse/sexp.h (working copy) @@ -598,6 +598,10 @@ #define OP_IS_FACING (0x00db | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // The E #define OP_FORCE_GLIDE (0x00dc | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // The E #define OP_TURRET_SET_RATE_OF_FIRE (0x00dd | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // FUBAR +#define OP_SHIP_SUBSYS_NO_REPLACE (0x00de | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // FUBAR +#define OP_SHIP_SUBSYS_NO_LIVE_DEBRIS (0x00df | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // FUBAR +#define OP_SHIP_SUBSYS_VANISHED (0x00e0 | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // FUBAR +#define OP_SHIP_SUBSYS_IGNORE_IF_DEAD (0x00e1 | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // FUBAR /* made obsolete by Goober5000 // debugging sexpressions |
|
Fixed in r6709 |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-10-22 04:27 | FUBAR-BDHR | New Issue | |
2010-10-22 04:27 | FUBAR-BDHR | File Added: 4subsys_and_untargetablefix.patch | |
2010-10-22 04:27 | FUBAR-BDHR | Status | new => assigned |
2010-10-22 04:27 | FUBAR-BDHR | Assigned To | => FUBAR-BDHR |
2010-11-04 05:41 | FUBAR-BDHR | Note Added: 0012438 | |
2010-11-04 05:41 | FUBAR-BDHR | Status | assigned => resolved |
2010-11-04 05:41 | FUBAR-BDHR | Fixed in Version | => 3.6.13 |
2010-11-04 05:41 | FUBAR-BDHR | Resolution | open => fixed |