1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/*
Standard object values.
*/
#include "swserv.h"
int NetHandleObjectValues(int condescriptor, char *arg)
{
static long object_num, con_object_num;
static int loc_type;
static long locked_on;
static long intercepting_object;
static int thrust_rev_state;
static double thrust_dir;
static double thrust;
static double throttle;
static int lighting; /* Real type is xswo_lighting_t. */
static double hp;
static double power;
static double antimatter;
static int shield_state;
static int selected_weapon;
static int cloak_state;
static double cloak_strength;
static double visibility;
static int damage_control;
static xsw_object_struct *obj_ptr;
con_object_num = connection[condescriptor]->object_num;
if(DBIsObjectGarbage(con_object_num))
return(-1);
else
obj_ptr = xsw_object[con_object_num];
/*
* SWEXTCMD_STDOBJVALS format:
*
* object_num,
* loc_type, locked_on, intercepting_object,
* thrust_rev_state, thrust_dir, thrust, throttle,
* lighting, hp, power,
* antimatter, shield_state, selected_weapon, cloak_state,
* cloak_strength, visibility, damage_control
*/
sscanf(arg,
"%ld\
%i %ld %ld\
%i %lf %lf %lf\
%i %lf %lf\
%lf %i %i %i\
%lf %lf %i",
&object_num,
&loc_type,
&locked_on,
&intercepting_object,
&thrust_rev_state,
&thrust_dir,
&thrust,
&throttle,
&lighting,
&hp,
&power,
&antimatter,
&shield_state,
&selected_weapon,
&cloak_state,
&cloak_strength,
&visibility,
&damage_control
);
/* Connection must own object. */
if(object_num != con_object_num)
return(-3);
/* Set throttle. */
if(throttle < 0.0)
throttle = 0.0;
else if(throttle > 1.0)
throttle = 1.0;
obj_ptr->throttle = throttle;
/* *** Everything else is tossed away. *** */
return(0);
}
int NetSendObjectValues(int condescriptor, long object_num)
{
static char sndbuf[CS_DATA_MAX_LEN];
static xsw_object_struct *obj_ptr;
if(DBIsObjectGarbage(object_num))
return(-1);
else
obj_ptr = xsw_object[object_num];
/*
* SWEXTCMD_STDOBJVALS format:
*
* object_num,
* loc_type, locked_on, intercepting_object,
* thrust_rev_state, thrust_dir, thrust, throttle,
* lighting, hp, power,
* antimatter, shield_state, selected_weapon, cloak_state,
* cloak_strength, visibility, damage_control
*/
sprintf(sndbuf,
"%i %i %ld\
%i %ld %ld\
%i %.4lf %.4lf %.4lf\
%i %.4lf %.4lf\
%.4lf %i %i\
%i %.4lf %.4lf %i\n",
CS_CODE_EXT,
SWEXTCMD_STDOBJVALS,
object_num,
obj_ptr->loc_type,
obj_ptr->locked_on,
obj_ptr->intercepting_object,
0, /* thrust_rev_state, no longer used. */
obj_ptr->thrust_dir,
obj_ptr->thrust,
obj_ptr->throttle,
obj_ptr->lighting,
obj_ptr->hp,
obj_ptr->power,
obj_ptr->antimatter,
obj_ptr->shield_state,
obj_ptr->selected_weapon,
obj_ptr->cloak_state,
obj_ptr->cloak_strength,
obj_ptr->visibility,
obj_ptr->damage_control
);
NetDoSend(condescriptor, sndbuf);
return(0);
}
|