Author Topic: A bunch of multi SEXP fixes  (Read 4313 times)

0 Members and 1 Guest are viewing this topic.

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
A bunch of multi SEXP fixes
Okay, so scattered reports have maintained that a few SEXPs still aren't multiplayer compatible.
I have created a test build that should fix 9 of these SEXPs, and a mission to test it. I have confirmed that this mission works fine by myself (obviously), but there's no point to this if it isn't tested in a proper multiplayer game. So, here is the link to a .rar file containing everything you need to test this thing.
It contains:
-a test build
-a test mission
-a .patch file (you don't need to touch this unless you're a coder)
-a readme, which has all the info you need to get set up with this thing.

This requires that you have BP multi set up, so if you don't, visit #multi-setup on IRC and they'll help you out.

Thanks in advance to anyone who tests this!

CommanderDJ

EDIT: Okay, so problems were encountered with the first build. Here is a build which attempts to rectify the issue. And for coders, here is the corresponding patch.
« Last Edit: May 19, 2011, 11:06:15 pm by CommanderDJ »
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
Re: A bunch of multi SEXP fixes
First post updated in response to problems encountered during initial testing.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline Parias

  • 27
Re: A bunch of multi SEXP fixes
Quote
For coders:
-The .patch is based off of r7195
The modified SEXPs are:
-set_camera_position
-set_camera_facing
-set_camera_facing_object
-set_camera_fov

So just to confirm then, does this mean we can have cutscene-ish functionaliy in multiplayer now?

(Yeah, I know this was last updated May 19th.. I feel dumb for missing this thread until now.)

 

Offline KyadCK

  • 29
  • Getting better with every game
    • Minecraft
    • Steam
Re: A bunch of multi SEXP fixes
To an extent, yes, using this build will allow for basic cutscene functionality in Multi. Unfortunately, things like the skybox mirroring, reset-camera not working, and others I have yet to fully test mean that the best we can hope for currently is something along the lines of changing the camera to look at a ship jumping out with cutscene bars, a fade-to-black and end mission.

Note that this patch is not in the nightlys, so you will have to use the build given here. The provded mission is a bust due to reset-camera being used very early, making it incapable of testing the needed sexps. Attatched is the WiH intro modified for multi to determine what sexps are broken, atleast from what was used. (on host-side, everything works just like single player. you need a 2nd player to even see what's wrong)

[attachment deleted by ninja]
Freespace Wallpapers     BluePlanet Multi     Minecraft Deimos Build Log
Need help setting up Multi? Then join us on the Multi-Setup IRC channel!
Computers only fear those who know how to use them

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: A bunch of multi SEXP fixes
This stuff never made it into trunk? If someone can get me a more recent patch I'll look it over and commit it tomorrow.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline KyadCK

  • 29
  • Getting better with every game
    • Minecraft
    • Steam
Re: A bunch of multi SEXP fixes
This is the most recent patch karajorma, the project to get this working was dropped not long after this.
Freespace Wallpapers     BluePlanet Multi     Minecraft Deimos Build Log
Need help setting up Multi? Then join us on the Multi-Setup IRC channel!
Computers only fear those who know how to use them

 

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
Re: A bunch of multi SEXP fixes
Sadly, Kyad is right. I had guessed that the reason for no multi functionality was that the SEXPs simply weren't multiplayer compatible. Upon testing, we found that some of them (reset-camera for instance) didn't work regardless. This quickly went beyond my feeble experience with the code, so there wasn't anything else I could do. I had heard that BPMulti had worked with Zacam to more closely identify which SEXPs weren't working, but beyond that I don't know of any progress with this.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: A bunch of multi SEXP fixes
I'll take a look at the patch you have so far and see what can be done. With the exception of SEXPs like key-pressed which would somehow have to send information back to the server there is no reason why SEXPs shouldn't be multi-compatible. I certainly haven't found anything in the Change section which doesn't work.


EDIT : I will need the patch itself. Seems Mediafire took it down.
« Last Edit: August 12, 2011, 03:16:16 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Re: A bunch of multi SEXP fixes
Code: (sexp.cpp) [Select]
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp (revision 7461)
+++ code/parse/sexp.cpp (working copy)
@@ -18253,8 +18253,41 @@
  }
 
  cam->set_position(&camera_vec, camera_time, camera_acc_time, camera_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_float(camera_vec.xyz.x);
+ multi_send_float(camera_vec.xyz.y);
+ multi_send_float(camera_vec.xyz.z);
+ multi_send_float(camera_time);
+ multi_send_float(camera_acc_time);
+ multi_send_float(camera_dec_time);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_camera_position()
+{
+ camera *cam = sexp_get_set_camera();
+
+ if(cam == NULL)
+ return;
+
+ vec3d camera_vec;
+ float camera_time = 0.0f;
+ float camera_acc_time = 0.0f;
+ float camera_dec_time = 0.0f;
+
+ multi_get_float(camera_vec.xyz.x);
+ multi_get_float(camera_vec.xyz.y);
+ multi_get_float(camera_vec.xyz.z);
+ multi_get_float(camera_time);
+ multi_get_float(camera_acc_time);
+ multi_get_float(camera_dec_time);
+
+ cam->set_position(&camera_vec, camera_time, camera_acc_time, camera_dec_time);
+}
+
 void sexp_set_camera_rotation(int n)
 {
  camera *cam = sexp_get_set_camera();
@@ -18324,32 +18357,43 @@
  }
 
  cam->set_rotation_facing(&location, rot_time, rot_acc_time, rot_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_float(location.xyz.x);
+ multi_send_float(location.xyz.y);
+ multi_send_float(location.xyz.z);
+ multi_send_float(rot_time);
+ multi_send_float(rot_acc_time);
+ multi_send_float(rot_dec_time);
+ multi_end_packet();
 }
 
-void sexp_set_camera_facing_object(int n)
+void multi_sexp_set_camera_facing()
 {
- char *object_name = CTEXT(n);
+ camera *cam = sexp_get_set_camera();
+ if(cam == NULL)
+ return;
+
+ vec3d location;
  float rot_time = 0.0f;
  float rot_acc_time = 0.0f;
  float rot_dec_time = 0.0f;
 
- //Now get the rotation time values
- n = CDR(n);
- if(n != -1)
- {
- rot_time = eval_num(n) / 1000.0f;
- n = CDR(n);
- if(n != -1)
- {
- rot_dec_time = rot_acc_time = eval_num(n) / 1000.0f;
- n = CDR(n);
- if(n != -1)
- {
- rot_dec_time = eval_num(n) / 1000.0f;
- }
- }
- }
+ multi_get_float(location.xyz.x);
+ multi_get_float(location.xyz.y);
+ multi_get_float(location.xyz.z);
+ multi_get_float(rot_time);
+ multi_get_float(rot_acc_time);
+ multi_get_float(rot_dec_time);
+
+ cam->set_rotation_facing(&location, rot_time, rot_acc_time, rot_dec_time);
+}
 
+//CommanderDJ
+//helper function for set_camera_facing_object
+void actually_set_camera_facing_object(char *object_name, float rot_time, float rot_acc_time, float rot_dec_time)
+{
  object_ship_wing_point_team oswpt;
  sexp_get_object_ship_wing_point_team(&oswpt, object_name);
 
@@ -18375,6 +18419,56 @@
  }
 }
 
+void sexp_set_camera_facing_object(int n)
+{
+ char *object_name = CTEXT(n);
+ float rot_time = 0.0f;
+ float rot_acc_time = 0.0f;
+ float rot_dec_time = 0.0f;
+
+ //Now get the rotation time values
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_time = eval_num(n) / 1000.0f;
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_dec_time = rot_acc_time = eval_num(n) / 1000.0f;
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_dec_time = eval_num(n) / 1000.0f;
+ }
+ }
+ }
+ actually_set_camera_facing_object(object_name, rot_time, rot_acc_time, rot_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_string(object_name);
+ multi_send_float(rot_time);
+ multi_send_float(rot_acc_time);
+ multi_send_float(rot_dec_time);
+ multi_end_packet();
+}
+
+//CommanderDJ
+void multi_sexp_set_camera_facing_object()
+{
+ char *object_name;
+ float rot_time = 0.0f;
+ float rot_acc_time = 0.0f;
+ float rot_dec_time = 0.0f;
+
+ multi_get_string(object_name);
+ multi_get_float(rot_time);
+ multi_get_float(rot_acc_time);
+ multi_get_float(rot_dec_time);
+
+ actually_set_camera_facing_object(object_name, rot_time, rot_acc_time, rot_dec_time);
+}
+
 extern float VIEWER_ZOOM_DEFAULT;
 void sexp_set_camera_fov(int n)
 {
@@ -18407,8 +18501,37 @@
  }
 
  cam->set_fov(camera_fov, camera_time, camera_acc_time, camera_dec_time);
+
+
+ multi_start_packet();
+ multi_send_float(camera_fov);
+ multi_send_float(camera_time);
+ multi_send_float(camera_acc_time);
+ multi_send_float(camera_dec_time);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_camera_fov()
+{
+ camera *cam = sexp_get_set_camera();
+
+ if(cam == NULL)
+ return;
+
+ float camera_fov = VIEWER_ZOOM_DEFAULT;
+ float camera_time = 0.0f;
+ float camera_acc_time = 0.0f;
+ float camera_dec_time = 0.0f;
+
+ multi_get_float(camera_fov);
+ multi_get_float(camera_time);
+ multi_get_float(camera_acc_time);
+ multi_get_float(camera_dec_time);
+
+ cam->set_fov(camera_fov, camera_time, camera_acc_time, camera_dec_time);
+}
+
 //Internal helper function for set-target and set-host
 object *sexp_camera_get_objsub(int node, int *o_submodel)
 {
@@ -18543,6 +18666,19 @@
  cam_reset_camera();
 }
 
+void multi_sexp_reset_camera(int node)
+{
+ camera *cam = cam_get_current().getCamera();
+ if(cam != NULL)
+ {
+ if(is_sexp_true(node))
+ {
+ cam->reset();
+ }
+ }
+ cam_reset_camera();
+}
+
 void sexp_show_subtitle(int node)
 {
  //These should be set to the default if not required to be explicitly defined
@@ -19011,7 +19147,7 @@
  multi_end_packet();
 }
 
-void multi_sexp_set_jumpnode_name(int n) //CommanderDJ
+void multi_sexp_set_jumpnode_name() //CommanderDJ
 {
  char *old_name = "\0";
 
@@ -19036,11 +19172,52 @@
  if(jnp==NULL)
  return;
 
+ char* jumpnode_name = CTEXT(n); //for multi
+
  n=CDR(n);
 
- jnp->set_alphacolor(eval_num(n),eval_num(CDR(n)),eval_num(CDR(CDR(n))),eval_num(CDR(CDR(CDR(n)))));
+ int red = eval_num(n);
+
+ int green = eval_num(CDR(n));
+
+ int blue = eval_num(CDR(CDR(n)));
+
+ int alpha = eval_num(CDR(CDR(CDR(n))));
+
+ jnp->set_alphacolor(red, green, blue, alpha);
+
+ multi_start_packet();
+ multi_send_string(jumpnode_name);
+ multi_send_int(red);
+ multi_send_int(green);
+ multi_send_int(blue);
+ multi_send_int(alpha);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_jumpnode_color()
+{
+ char* jumpnode_name;
+
+ multi_get_string(jumpnode_name);
+
+ //I put this here to prevent the unnecessary transfer of the ints if the jumpnode is invalid
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp==NULL)
+ return;
+
+ int red, blue, green, alpha;
+
+ multi_get_int(red);
+ multi_get_int(green);
+ multi_get_int(blue);
+ multi_get_int(alpha);
+
+ jnp->set_alphacolor(red, green, blue, alpha);
+}
+
 void sexp_set_jumpnode_model(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
@@ -19048,27 +19225,92 @@
  if(jnp==NULL)
  return;
 
- n=CDR(n);
+ char* jumpnode_name = CTEXT(n);
 
- jnp->set_model(CTEXT(n), is_sexp_true(CDR(n)) != 0);
+ char* model_name = CTEXT(CDR(n));
+
+ bool show_polys = CDR(CDR(n));
+
+ jnp->set_model(model_name, (is_sexp_true(show_polys) != 0));
+
+ multi_start_packet();
+ multi_send_string(jumpnode_name);
+ multi_send_string(model_name);
+ multi_send_bool(show_polys);
+ multi_end_packet();
 }
 
+void multi_sexp_set_jumpnode_model()
+{
+ char* jumpnode_name;
+
+ multi_get_string(jumpnode_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp==NULL)
+ return;
+
+ char* model_name;
+
+ multi_get_string(model_name);
+
+ bool show_polys;
+
+ show_polys = multi_get_bool(show_polys);
+
+ jnp->set_model(model_name, (is_sexp_true(show_polys) != 0));
+
+}
+
 void sexp_show_jumpnode(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
 
  if(jnp!=NULL)
  jnp->show(true);
+
+ multi_start_packet();
+ multi_send_string(CTEXT(n));
+ multi_end_packet();
 }
 
+void multi_sexp_show_jumpnode()
+{
+ char* jumpnode_name;
+
+ multi_get_string(jumpnode_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp!=NULL)
+ jnp->show(true);
+}
+
 void sexp_hide_jumpnode(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
 
  if(jnp!=NULL)
  jnp->show(false);
+
+ multi_start_packet();
+ multi_send_string(CTEXT(n));
+ multi_end_packet();
 }
 
+void multi_sexp_hide_jumpnode()
+{
+ char* jumpnode_name;
+
+ multi_get_string(jumpnode_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp!=NULL)
+ jnp->show(false);
+}
+
 //WMC - This is a bit of a hack, however, it's easier than
 //coding in a whole new SCript_system function.
 int sexp_script_eval(int node, int return_type)
@@ -21622,18 +21864,54 @@
  multi_sexp_toggle_cutscene_bars(op_num == OP_CUTSCENES_SET_CUTSCENE_BARS );
  break;
 
+ case OP_CUTSCENES_SET_CAMERA_FACING:
+ multi_sexp_set_camera_facing();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_FACING_OBJECT:
+ multi_sexp_set_camera_facing_object();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_FOV:
+ multi_sexp_set_camera_fov();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_POSITION:
+ multi_sexp_set_camera_position();
+ break;
+
  case OP_SET_CAMERA_SHUDDER:
  multi_sexp_set_camera_shudder();
  break;
 
+ case OP_CUTSCENES_RESET_CAMERA:
+ multi_sexp_reset_camera(op_num == OP_CUTSCENES_RESET_CAMERA);
+ break;
+
  case OP_JUMP_NODE_SET_JUMPNODE_NAME:
- multi_sexp_set_jumpnode_name(op_num == OP_JUMP_NODE_SET_JUMPNODE_NAME);
+ multi_sexp_set_jumpnode_name();
  break;
 
  case OP_IGNORE_KEY:
  multi_sexp_ignore_key();
  break;
 
+ case OP_JUMP_NODE_SET_JUMPNODE_COLOR:
+ multi_sexp_set_jumpnode_color();
+ break;
+
+ case OP_JUMP_NODE_SET_JUMPNODE_MODEL:
+ multi_sexp_set_jumpnode_model();
+ break;
+
+ case OP_JUMP_NODE_SHOW_JUMPNODE:
+ multi_sexp_show_jumpnode();
+ break;
+
+ case OP_JUMP_NODE_HIDE_JUMPNODE:
+ multi_sexp_hide_jumpnode();
+ break;
+
  // bad sexp in the packet
  default:
  // probably just a version error where the host supports a SEXP but a client does not

Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: A bunch of multi SEXP fixes
Thanks. I'll look at that right now.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: A bunch of multi SEXP fixes
Checked quickly and this seems to work now. CommanderDJ's code needed some minor fixes but for the most part worked. One short cut he took exposed a rather dangerous flaw in the multiplayer-SEXP system though so the patch also includes changes designed to fix that too.

Code: [Select]
Index: code/network/multi_sexp.cpp
===================================================================
--- code/network/multi_sexp.cpp (revision 7475)
+++ code/network/multi_sexp.cpp (working copy)
@@ -318,6 +318,39 @@
 
 int multi_sexp_get_next_operator()
 {
+ if (current_argument_count != 0) {
+ // we have a problem here, either the argument count is wrong or the last SEXP didn't remove all its data from the packet
+ ubyte possible_terminator;
+ bool terminator_found = false;
+ for (int i=0; i < current_argument_count ; i++) {
+ GET_DATA(possible_terminator);
+ Multi_sexp_bytes_left--;
+
+ if (possible_terminator == PACKET_TERMINATOR) {
+ Warning(LOCATION, "%s has returned to multi_sexp_eval() claiming %d arguments left. %d actually found. Trace out and fix this!"), Operators[op_num].text, current_argument_count, i;
+ terminator_found = true;
+ break;
+ }
+ }
+
+ // if we still haven't found the terminator it probably means the last SEXP didn't remove all its data from the packet
+ if (!terminator_found) {
+ GET_DATA(possible_terminator);
+ Multi_sexp_bytes_left--;
+
+ if (possible_terminator != PACKET_TERMINATOR) {
+ // discard remainder of packet if we still haven't found the terminator as it is hopelessly corrupt
+ Warning(LOCATION, "%s has returned to multi_sexp_eval() without finding the terminator. Discarding packet! Trace out and fix this!", Operators[op_num].text);
+ Multi_sexp_bytes_left = 0;
+ return -1;
+ }
+ else {
+ Warning(LOCATION, "%s has returned to multi_sexp_eval() without removing all its data from the packet. Trace out and fix this!", Operators[op_num].text);
+ op_num = -1;
+ }
+ }
+ }
+
  GET_INT(op_num);
  Multi_sexp_bytes_left -= sizeof(int);
  GET_INT(current_argument_count);
@@ -493,3 +526,10 @@
 
  return true;
 }
+
+void multi_discard_remaining_packet()
+{
+ if (!multi_sexp_discard_operator()) {
+ Warning(LOCATION, "Attempt to discard SEXP packet failed! Operator %d packet lacks proper termination. Entire packet may be corrupt. Discarding remaining packet");
+ }
+}
\ No newline at end of file
Index: code/network/multi_sexp.h
===================================================================
--- code/network/multi_sexp.h (revision 7475)
+++ code/network/multi_sexp.h (working copy)
@@ -14,7 +14,7 @@
 void multi_end_packet();
 void multi_sexp_flush_packet();
 
-// data fillers
+// server side packet fillers
 void multi_send_int(int value);
 void multi_send_ship(ship *shipp);
 void multi_send_ship(int shipnum);
@@ -28,6 +28,9 @@
 int multi_sexp_get_operator();
 bool multi_sexp_discard_operator();
 
+void multi_discard_remaining_packet();
+
+// client side packet emptiers
 bool multi_get_int(int &value);
 bool multi_get_ship(int &value);
 bool multi_get_ship(ship*& shipp);
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp (revision 7475)
+++ code/parse/sexp.cpp (working copy)
@@ -18253,8 +18253,43 @@
  }
 
  cam->set_position(&camera_vec, camera_time, camera_acc_time, camera_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_float(camera_vec.xyz.x);
+ multi_send_float(camera_vec.xyz.y);
+ multi_send_float(camera_vec.xyz.z);
+ multi_send_float(camera_time);
+ multi_send_float(camera_acc_time);
+ multi_send_float(camera_dec_time);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_camera_position()
+{
+ camera *cam = sexp_get_set_camera();
+
+ if(cam == NULL) {
+ Int3();
+ return;
+ }
+
+ vec3d camera_vec;
+ float camera_time = 0.0f;
+ float camera_acc_time = 0.0f;
+ float camera_dec_time = 0.0f;
+
+ multi_get_float(camera_vec.xyz.x);
+ multi_get_float(camera_vec.xyz.y);
+ multi_get_float(camera_vec.xyz.z);
+ multi_get_float(camera_time);
+ multi_get_float(camera_acc_time);
+ multi_get_float(camera_dec_time);
+
+ cam->set_position(&camera_vec, camera_time, camera_acc_time, camera_dec_time);
+}
+
 void sexp_set_camera_rotation(int n)
 {
  camera *cam = sexp_get_set_camera();
@@ -18324,32 +18359,43 @@
  }
 
  cam->set_rotation_facing(&location, rot_time, rot_acc_time, rot_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_float(location.xyz.x);
+ multi_send_float(location.xyz.y);
+ multi_send_float(location.xyz.z);
+ multi_send_float(rot_time);
+ multi_send_float(rot_acc_time);
+ multi_send_float(rot_dec_time);
+ multi_end_packet();
 }
 
-void sexp_set_camera_facing_object(int n)
+void multi_sexp_set_camera_facing()
 {
- char *object_name = CTEXT(n);
+ camera *cam = sexp_get_set_camera();
+ if(cam == NULL)
+ return;
+
+ vec3d location;
  float rot_time = 0.0f;
  float rot_acc_time = 0.0f;
  float rot_dec_time = 0.0f;
 
- //Now get the rotation time values
- n = CDR(n);
- if(n != -1)
- {
- rot_time = eval_num(n) / 1000.0f;
- n = CDR(n);
- if(n != -1)
- {
- rot_dec_time = rot_acc_time = eval_num(n) / 1000.0f;
- n = CDR(n);
- if(n != -1)
- {
- rot_dec_time = eval_num(n) / 1000.0f;
- }
- }
- }
+ multi_get_float(location.xyz.x);
+ multi_get_float(location.xyz.y);
+ multi_get_float(location.xyz.z);
+ multi_get_float(rot_time);
+ multi_get_float(rot_acc_time);
+ multi_get_float(rot_dec_time);
+
+ cam->set_rotation_facing(&location, rot_time, rot_acc_time, rot_dec_time);
+}
 
+//CommanderDJ
+//helper function for set_camera_facing_object
+void actually_set_camera_facing_object(char *object_name, float rot_time, float rot_acc_time, float rot_dec_time)
+{
  object_ship_wing_point_team oswpt;
  sexp_get_object_ship_wing_point_team(&oswpt, object_name);
 
@@ -18375,6 +18421,56 @@
  }
 }
 
+void sexp_set_camera_facing_object(int n)
+{
+ char *object_name = CTEXT(n);
+ float rot_time = 0.0f;
+ float rot_acc_time = 0.0f;
+ float rot_dec_time = 0.0f;
+
+ //Now get the rotation time values
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_time = eval_num(n) / 1000.0f;
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_dec_time = rot_acc_time = eval_num(n) / 1000.0f;
+ n = CDR(n);
+ if(n != -1)
+ {
+ rot_dec_time = eval_num(n) / 1000.0f;
+ }
+ }
+ }
+ actually_set_camera_facing_object(object_name, rot_time, rot_acc_time, rot_dec_time);
+
+ //multiplayer callback
+ multi_start_packet();
+ multi_send_string(object_name);
+ multi_send_float(rot_time);
+ multi_send_float(rot_acc_time);
+ multi_send_float(rot_dec_time);
+ multi_end_packet();
+}
+
+//CommanderDJ
+void multi_sexp_set_camera_facing_object()
+{
+ char object_name[TOKEN_LENGTH];
+ float rot_time = 0.0f;
+ float rot_acc_time = 0.0f;
+ float rot_dec_time = 0.0f;
+
+ multi_get_string(object_name);
+ multi_get_float(rot_time);
+ multi_get_float(rot_acc_time);
+ multi_get_float(rot_dec_time);
+
+ actually_set_camera_facing_object(object_name, rot_time, rot_acc_time, rot_dec_time);
+}
+
 extern float VIEWER_ZOOM_DEFAULT;
 void sexp_set_camera_fov(int n)
 {
@@ -18407,8 +18503,37 @@
  }
 
  cam->set_fov(camera_fov, camera_time, camera_acc_time, camera_dec_time);
+
+
+ multi_start_packet();
+ multi_send_float(camera_fov);
+ multi_send_float(camera_time);
+ multi_send_float(camera_acc_time);
+ multi_send_float(camera_dec_time);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_camera_fov()
+{
+ camera *cam = sexp_get_set_camera();
+
+ if(cam == NULL)
+ return;
+
+ float camera_fov = VIEWER_ZOOM_DEFAULT;
+ float camera_time = 0.0f;
+ float camera_acc_time = 0.0f;
+ float camera_dec_time = 0.0f;
+
+ multi_get_float(camera_fov);
+ multi_get_float(camera_time);
+ multi_get_float(camera_acc_time);
+ multi_get_float(camera_dec_time);
+
+ cam->set_fov(camera_fov, camera_time, camera_acc_time, camera_dec_time);
+}
+
 //Internal helper function for set-target and set-host
 object *sexp_camera_get_objsub(int node, int *o_submodel)
 {
@@ -18538,11 +18663,23 @@
  if(is_sexp_true(node))
  {
  cam->reset();
+ multi_start_packet();
+ multi_end_packet();
  }
  }
  cam_reset_camera();
 }
 
+void multi_sexp_reset_camera()
+{
+ camera *cam = cam_get_current().getCamera();
+ if(cam != NULL)
+ {
+ cam->reset();
+ }
+ cam_reset_camera();
+}
+
 void sexp_show_subtitle(int node)
 {
  //These should be set to the default if not required to be explicitly defined
@@ -18992,18 +19129,18 @@
 void sexp_set_jumpnode_name(int n) //CommanderDJ
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
-
+
+ char *new_name = CTEXT(n); //for multi
  char *old_name = CTEXT(n); //for multi
 
- if(jnp==NULL)
+ if(jnp==NULL) {
  return;
+ }
 
  n=CDR(n);
 
  jnp->set_name(CTEXT(n));
 
- char *new_name = CTEXT(n); //for multi
-
  //multiplayer callback
  multi_start_packet();
  multi_send_string(old_name);
@@ -19011,14 +19148,12 @@
  multi_end_packet();
 }
 
-void multi_sexp_set_jumpnode_name(int n) //CommanderDJ
+void multi_sexp_set_jumpnode_name() //CommanderDJ
 {
- char *old_name = "\0";
+ char old_name[TOKEN_LENGTH];
+ char new_name[TOKEN_LENGTH];
 
  multi_get_string(old_name);
-
- char *new_name = "\0";
-
  multi_get_string(new_name);
 
  jump_node *jnp = jumpnode_get_by_name(old_name);
@@ -19036,11 +19171,51 @@
  if(jnp==NULL)
  return;
 
+ char* jumpnode_name = CTEXT(n); //for multi
+
  n=CDR(n);
 
- jnp->set_alphacolor(eval_num(n),eval_num(CDR(n)),eval_num(CDR(CDR(n))),eval_num(CDR(CDR(CDR(n)))));
+ int red = eval_num(n);
+
+ int green = eval_num(CDR(n));
+
+ int blue = eval_num(CDR(CDR(n)));
+
+ int alpha = eval_num(CDR(CDR(CDR(n))));
+
+ jnp->set_alphacolor(red, green, blue, alpha);
+
+ multi_start_packet();
+ multi_send_string(jumpnode_name);
+ multi_send_int(red);
+ multi_send_int(green);
+ multi_send_int(blue);
+ multi_send_int(alpha);
+ multi_end_packet();
 }
 
+//CommanderDJ
+void multi_sexp_set_jumpnode_color()
+{
+ char jumpnode_name[TOKEN_LENGTH] ;
+ int red, blue, green, alpha;
+
+ multi_get_string(jumpnode_name);
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp==NULL) {
+ multi_discard_remaining_packet();
+ return;
+ }
+
+ multi_get_int(red);
+ multi_get_int(green);
+ multi_get_int(blue);
+ multi_get_int(alpha);
+
+ jnp->set_alphacolor(red, green, blue, alpha);
+}
+
 void sexp_set_jumpnode_model(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
@@ -19048,27 +19223,90 @@
  if(jnp==NULL)
  return;
 
- n=CDR(n);
+ char* jumpnode_name = CTEXT(n);
 
- jnp->set_model(CTEXT(n), is_sexp_true(CDR(n)) != 0);
+ char* model_name = CTEXT(CDR(n));
+
+ bool show_polys = CDR(CDR(n));
+
+ jnp->set_model(model_name, (is_sexp_true(show_polys) != 0));
+
+ multi_start_packet();
+ multi_send_string(jumpnode_name);
+ multi_send_string(model_name);
+ multi_send_bool(show_polys);
+ multi_end_packet();
 }
 
+void multi_sexp_set_jumpnode_model()
+{
+ char jumpnode_name[TOKEN_LENGTH];
+ char model_name[TOKEN_LENGTH];
+
+ multi_get_string(jumpnode_name);
+ multi_get_string(model_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp==NULL)
+ return;
+
+ bool show_polys;
+
+ show_polys = multi_get_bool(show_polys);
+
+ jnp->set_model(model_name, (is_sexp_true(show_polys) != 0));
+
+}
+
 void sexp_show_jumpnode(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
 
  if(jnp!=NULL)
  jnp->show(true);
+
+ multi_start_packet();
+ multi_send_string(CTEXT(n));
+ multi_end_packet();
 }
 
+void multi_sexp_show_jumpnode()
+{
+ char jumpnode_name[TOKEN_LENGTH] ;
+
+ multi_get_string(jumpnode_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp!=NULL)
+ jnp->show(true);
+}
+
 void sexp_hide_jumpnode(int n)
 {
  jump_node *jnp = jumpnode_get_by_name(CTEXT(n));
 
  if(jnp!=NULL)
  jnp->show(false);
+
+ multi_start_packet();
+ multi_send_string(CTEXT(n));
+ multi_end_packet();
 }
 
+void multi_sexp_hide_jumpnode()
+{
+ char jumpnode_name[TOKEN_LENGTH] ;
+
+ multi_get_string(jumpnode_name);
+
+ jump_node *jnp = jumpnode_get_by_name(jumpnode_name);
+
+ if(jnp!=NULL)
+ jnp->show(false);
+}
+
 //WMC - This is a bit of a hack, however, it's easier than
 //coding in a whole new SCript_system function.
 int sexp_script_eval(int node, int return_type)
@@ -21622,18 +21860,54 @@
  multi_sexp_toggle_cutscene_bars(op_num == OP_CUTSCENES_SET_CUTSCENE_BARS );
  break;
 
+ case OP_CUTSCENES_SET_CAMERA_FACING:
+ multi_sexp_set_camera_facing();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_FACING_OBJECT:
+ multi_sexp_set_camera_facing_object();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_FOV:
+ multi_sexp_set_camera_fov();
+ break;
+
+ case OP_CUTSCENES_SET_CAMERA_POSITION:
+ multi_sexp_set_camera_position();
+ break;
+
  case OP_SET_CAMERA_SHUDDER:
  multi_sexp_set_camera_shudder();
  break;
 
+ case OP_CUTSCENES_RESET_CAMERA:
+ multi_sexp_reset_camera();
+ break;
+
  case OP_JUMP_NODE_SET_JUMPNODE_NAME:
- multi_sexp_set_jumpnode_name(op_num == OP_JUMP_NODE_SET_JUMPNODE_NAME);
+ multi_sexp_set_jumpnode_name();
  break;
 
  case OP_IGNORE_KEY:
  multi_sexp_ignore_key();
  break;
 
+ case OP_JUMP_NODE_SET_JUMPNODE_COLOR:
+ multi_sexp_set_jumpnode_color();
+ break;
+
+ case OP_JUMP_NODE_SET_JUMPNODE_MODEL:
+ multi_sexp_set_jumpnode_model();
+ break;
+
+ case OP_JUMP_NODE_SHOW_JUMPNODE:
+ multi_sexp_show_jumpnode();
+ break;
+
+ case OP_JUMP_NODE_HIDE_JUMPNODE:
+ multi_sexp_hide_jumpnode();
+ break;
+
  // bad sexp in the packet
  default:
  // probably just a version error where the host supports a SEXP but a client does not
@@ -21642,7 +21916,7 @@
  }
  // a more major problem
  else {
- Warning(LOCATION, "Received invalid SEXP packet from host. Function involving operator %d lacks termination. Entire packet may be corrupt. Discarding remaining packet");
+ Warning(LOCATION, "Received invalid SEXP packet from host. Function involving operator %d lacks termination. Entire packet may be corrupt. Discarding remaining packet", op_num);
  Int3();
  return;
  }



[attachment deleted by ninja]
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Parias

  • 27
Re: A bunch of multi SEXP fixes
This is great, thank you very much - I've been long hoping to leverage this functionality for a co-op campaign.

I just tried out the initial build posted with my own test mission that starts with a cutscene  - the server launches great, but the client always crashes right away. I haven't been able to get more on why for lack of an associated debug build / properly configured dev environment, but is this the sort of thing your fixes would have possibly rectified Karajoma, and to this end, will we be seeing this functionality in the latest builds from now on?

 

Offline KyadCK

  • 29
  • Getting better with every game
    • Minecraft
    • Steam
Re: A bunch of multi SEXP fixes
New thread on the subject: http://www.hard-light.net/forums/index.php?topic=77775.msg1540446#msg1540446

I do not belive it is in trunk yet, but zacam provides a build and I linked a mission. Any help testing would be great.
Freespace Wallpapers     BluePlanet Multi     Minecraft Deimos Build Log
Need help setting up Multi? Then join us on the Multi-Setup IRC channel!
Computers only fear those who know how to use them

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: A bunch of multi SEXP fixes
So I'm gonna lock this one. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]