File: netwepvalues.c

package info (click to toggle)
xshipwars 1.32-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 17,176 kB
  • ctags: 6,357
  • sloc: ansic: 157,152; makefile: 226; sh: 75
file content (73 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download
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
#include "swserv.h" 
          


int NetHandleWeaponValues(int condescriptor, char *arg)
{
	return(0);
}
 
 
int NetSendWeaponValues(
	int condescriptor,
	long object_num, int weapon_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];


        /* weapon_num must be valid. */
        if((weapon_num < 0) ||
           (weapon_num >= obj_ptr->total_weapons) ||
           (weapon_num >= MAX_WEAPONS)
        )
            return(-1);


        /*
         *	SWEXTCMD_STDWEPVALS format:
         *
         *      object_num, weapon_num,
         *      ocs_code, emission_type, amount, max,
         *      power, range, create_power
         *      delay, last_used
         */
        sprintf(sndbuf,
"%i %i\
 %ld %i\
 %i %i %ld %ld\
 %.4lf %ld %.4lf\
 %ld %ld\n",
                CS_CODE_EXT,
                SWEXTCMD_STDWEPVALS,
        
                object_num,
                weapon_num,
        
                obj_ptr->weapons[weapon_num]->ocs_code,
                obj_ptr->weapons[weapon_num]->emission_type,
                obj_ptr->weapons[weapon_num]->amount,
                obj_ptr->weapons[weapon_num]->max,
            
                obj_ptr->weapons[weapon_num]->power,
                obj_ptr->weapons[weapon_num]->range,
                obj_ptr->weapons[weapon_num]->create_power,
            
                obj_ptr->weapons[weapon_num]->delay,
                obj_ptr->weapons[weapon_num]->last_used
        );  


        /* Send data. */
        NetDoSend(condescriptor, sndbuf);


        return(0);
}