FS2_Open
Open source remastering of the Freespace 2 engine
multi_sexp.cpp File Reference
#include "network/multi_sexp.h"
#include "network/psnet2.h"
#include "network/multimsgs.h"
#include "parse/sexp.h"
#include "network/multi.h"
#include "network/multiutil.h"

Go to the source code of this file.

Macros

#define CALLBACK_TERMINATOR   255
 
#define TYPE_NOT_DATA   255
 
#define TYPE_SEXP_OPERATOR   0
 
#define TYPE_ARGUMENT_COUNT   1
 
#define TYPE_DATA_TERMINATES   2
 
#define TYPE_INT   3
 
#define TYPE_SHIP   4
 
#define TYPE_STRING   5
 
#define TYPE_PARSE_OBJECT   6
 
#define TYPE_BOOLEAN   7
 
#define TYPE_FLOAT   8
 
#define TYPE_SHORT   9
 
#define TYPE_USHORT   10
 
#define TYPE_OBJECT   11
 

Functions

void multi_sexp_ensure_space_remains (int data_size)
 
void initalise_sexp_packet ()
 
void multi_start_callback ()
 
void multi_end_callback ()
 
void multi_do_callback ()
 
void multi_sexp_flush_packet ()
 
bool cannot_send_data ()
 
void multi_send_int (int value)
 
void multi_send_ship (int shipnum)
 
void multi_send_ship (ship *shipp)
 
void multi_send_object (object *objp)
 
void multi_send_parse_object (p_object *pobjp)
 
void multi_send_string (char *string)
 
void multi_send_string (const SCP_string &string)
 
void multi_send_bool (bool value)
 
void multi_send_float (float value)
 
void multi_send_short (short value)
 
void multi_send_ushort (ushort value)
 
void sexp_packet_received (ubyte *received_packet, int num_ubytes)
 
bool argument_count_is_valid ()
 
int multi_sexp_get_next_operator ()
 
int multi_sexp_get_operator ()
 
void multi_reduce_counts (int amount)
 
void multi_finished_callback ()
 
bool multi_sexp_discard_operator ()
 
bool multi_get_int (int &value)
 
bool multi_get_ship (int &value)
 
bool multi_get_ship (ship *&shipp)
 
bool multi_get_object (object *&objp)
 
bool multi_get_parse_object (p_object *&pobjp)
 
bool multi_get_string (char *buffer)
 
bool multi_get_string (SCP_string &buffer)
 
bool multi_get_bool (bool &value)
 
bool multi_get_float (float &value)
 
bool multi_get_short (short &value)
 
bool multi_get_ushort (ushort &value)
 
void multi_discard_remaining_callback_data ()
 

Variables

int TEMP_DATA_SIZE = -1
 
ubyte type [MAX_PACKET_SIZE]
 
int argument_count_index = -1
 
int current_argument_count = 0
 
ubyte data [MAX_PACKET_SIZE]
 
int packet_size = 0
 
int offset = 0
 
bool callback_started = false
 
int Multi_sexp_bytes_left = 0
 
int op_num = -1
 
bool packet_flagged_invalid = false
 

Macro Definition Documentation

#define CALLBACK_TERMINATOR   255

Definition at line 14 of file multi_sexp.cpp.

#define TYPE_ARGUMENT_COUNT   1

Definition at line 19 of file multi_sexp.cpp.

#define TYPE_BOOLEAN   7

Definition at line 25 of file multi_sexp.cpp.

#define TYPE_DATA_TERMINATES   2

Definition at line 20 of file multi_sexp.cpp.

#define TYPE_FLOAT   8

Definition at line 26 of file multi_sexp.cpp.

#define TYPE_INT   3

Definition at line 21 of file multi_sexp.cpp.

#define TYPE_NOT_DATA   255

Definition at line 17 of file multi_sexp.cpp.

#define TYPE_OBJECT   11

Definition at line 29 of file multi_sexp.cpp.

#define TYPE_PARSE_OBJECT   6

Definition at line 24 of file multi_sexp.cpp.

#define TYPE_SEXP_OPERATOR   0

Definition at line 18 of file multi_sexp.cpp.

#define TYPE_SHIP   4

Definition at line 22 of file multi_sexp.cpp.

#define TYPE_SHORT   9

Definition at line 27 of file multi_sexp.cpp.

#define TYPE_STRING   5

Definition at line 23 of file multi_sexp.cpp.

#define TYPE_USHORT   10

Definition at line 28 of file multi_sexp.cpp.

Function Documentation

bool argument_count_is_valid ( )

Checks that the previous SEXP in the packet has correctly removed all its data from the packet. Attempts to fix it if it hasn't.

Definition at line 480 of file multi_sexp.cpp.

bool cannot_send_data ( )

Checks if the SEXP packet is ready to recieve data.

Definition at line 236 of file multi_sexp.cpp.

void initalise_sexp_packet ( )

Set up the SEXP packet every frame when the game starts processing SEXPs.

Definition at line 62 of file multi_sexp.cpp.

void multi_discard_remaining_callback_data ( )

attempts to remove all remaining data for the current operator.

Definition at line 819 of file multi_sexp.cpp.

void multi_do_callback ( )

Convenience function that simply calls the two functions above. Used when the server merely needs to signal the clients that a SEXP has been processed but no additional data needs to be sent.

Definition at line 142 of file multi_sexp.cpp.

void multi_end_callback ( )

Called when a server has written all the data it needs to write for this SEXP.

Definition at line 107 of file multi_sexp.cpp.

void multi_finished_callback ( )

Called when the SEXP code has finished processing the current SEXP.

Definition at line 562 of file multi_sexp.cpp.

bool multi_get_bool ( bool &  value)

Attempts to remove a boolean from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 759 of file multi_sexp.cpp.

bool multi_get_float ( float value)

Attempts to remove a float from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 774 of file multi_sexp.cpp.

bool multi_get_int ( int value)

Attempts to remove an int from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 616 of file multi_sexp.cpp.

bool multi_get_object ( object *&  objp)

Attempts to get an object pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. Returns false if unable to do so.

Definition at line 676 of file multi_sexp.cpp.

bool multi_get_parse_object ( p_object *&  pobjp)

Attempts to get a parse objects pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. Returns false if unable to do so.

Definition at line 702 of file multi_sexp.cpp.

bool multi_get_ship ( int value)

Attempts to get an index for the Ships array based on the net sig it removes from the SEXP packet. Returns it as the value parameter. Returns false if unable to do so.

Definition at line 632 of file multi_sexp.cpp.

bool multi_get_ship ( ship *&  shipp)

Attempts to get a ship pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. Returns false if unable to do so.

Definition at line 660 of file multi_sexp.cpp.

bool multi_get_short ( short &  value)

Attempts to remove a short from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 789 of file multi_sexp.cpp.

bool multi_get_string ( char *  buffer)

Attempts to remove a string from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 726 of file multi_sexp.cpp.

bool multi_get_string ( SCP_string buffer)

Definition at line 740 of file multi_sexp.cpp.

bool multi_get_ushort ( ushort value)

Attempts to remove an unsigned short from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so.

Definition at line 804 of file multi_sexp.cpp.

void multi_reduce_counts ( int  amount)

Ensures that the variables tracking how much data is left in the packet are updated correctly when data is removed.

Definition at line 549 of file multi_sexp.cpp.

void multi_send_bool ( bool  value)

Add a boolean to the SEXP packet.

Definition at line 379 of file multi_sexp.cpp.

void multi_send_float ( float  value)

Add a float to the SEXP packet.

Definition at line 398 of file multi_sexp.cpp.

void multi_send_int ( int  value)

Add an int to the SEXP packet.

Definition at line 257 of file multi_sexp.cpp.

void multi_send_object ( object objp)

Add the net sig of an object to the SEXP packet.

Definition at line 308 of file multi_sexp.cpp.

void multi_send_parse_object ( p_object pobjp)

Add the net sig of a parse object to the SEXP packet.

Definition at line 326 of file multi_sexp.cpp.

void multi_send_ship ( int  shipnum)

Adds a ship's net sig to the SEXP packet.

Definition at line 276 of file multi_sexp.cpp.

void multi_send_ship ( ship shipp)

Adds a ship's net sig to the SEXP packet.

Definition at line 290 of file multi_sexp.cpp.

void multi_send_short ( short  value)

Add a short to the SEXP packet.

Definition at line 417 of file multi_sexp.cpp.

void multi_send_string ( char *  string)

Add a string to the SEXP packet. Should only be used for strings TOKEN_LENGTH in size or smaller.

Definition at line 344 of file multi_sexp.cpp.

void multi_send_string ( const SCP_string string)

Definition at line 360 of file multi_sexp.cpp.

void multi_send_ushort ( ushort  value)

Add an unsigned short to the SEXP packet.

Definition at line 436 of file multi_sexp.cpp.

bool multi_sexp_discard_operator ( )

Used to discard the rest of a callback on the client machine.

Definition at line 583 of file multi_sexp.cpp.

void multi_sexp_ensure_space_remains ( int  data_size)

Checks if there is enough space in the packet currently being stuffed for the data that is about to be written into it

If there is not enough space, it will send everything in the packet apart from any data from the SEXP currently being processed and then create a new packet containing the data for this SEXP only.

Definition at line 154 of file multi_sexp.cpp.

void multi_sexp_flush_packet ( )

Flushes out the SEXP packet and sends any data still in there. Called when the game finishes processing SEXPs.

Definition at line 215 of file multi_sexp.cpp.

int multi_sexp_get_next_operator ( )

Gets the next operator from the SEXP packet. Returns the number of the operator or -1 if there are no more operators because the packet is corrupt.

Definition at line 523 of file multi_sexp.cpp.

int multi_sexp_get_operator ( )

Returns the current operator number but does not touch the SEXP packet.

Definition at line 541 of file multi_sexp.cpp.

void multi_start_callback ( )

Called when a server is currently processing a SEXP that needs to send an update to the clients.

Definition at line 79 of file multi_sexp.cpp.

void sexp_packet_received ( ubyte received_packet,
int  num_ubytes 
)

Called when the client recieves a SEXP packet from the server. Removes the data from the packet that underlying code uses and puts into a new array that will work with the rest of the client-side code.

Definition at line 461 of file multi_sexp.cpp.

Variable Documentation

int argument_count_index = -1

Definition at line 36 of file multi_sexp.cpp.

bool callback_started = false

Definition at line 44 of file multi_sexp.cpp.

int current_argument_count = 0

Definition at line 37 of file multi_sexp.cpp.

Definition at line 40 of file multi_sexp.cpp.

int Multi_sexp_bytes_left = 0

Definition at line 46 of file multi_sexp.cpp.

int offset = 0

Definition at line 42 of file multi_sexp.cpp.

int op_num = -1

Definition at line 48 of file multi_sexp.cpp.

bool packet_flagged_invalid = false

Definition at line 49 of file multi_sexp.cpp.

int packet_size = 0

Definition at line 41 of file multi_sexp.cpp.

int TEMP_DATA_SIZE = -1

Definition at line 15 of file multi_sexp.cpp.

Definition at line 35 of file multi_sexp.cpp.