File: netscore.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 (81 lines) | stat: -rw-r--r-- 1,474 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
74
75
76
77
78
79
80
81
#include "swserv.h"



int NetHandleScore(int condescriptor, char *arg)
{
	long object_num;
        xsw_object_struct *obj_ptr;


        /*
         *      SWEXTCMD_SETSCORE format:
         *
         *      object_num
         *      credits rmu rmu_max damage_given damage_recieved
         *      kills
         */
        sscanf(arg,
		"%ld",
                &object_num
        );

	if(DBIsObjectGarbage(object_num))
	    return(-1);
	else
	    obj_ptr = xsw_object[object_num];


	NetSendScore(condescriptor, object_num);


        return(0);
}


int NetSendScore(
	int condescriptor,
	long object_num
)
{
	char sndbuf[CS_DATA_MAX_LEN];
	xsw_object_struct *obj_ptr;
	xsw_score_struct *score_ptr;


	if(DBIsObjectGarbage(object_num))
	    return(-1);
	else
	    obj_ptr = xsw_object[object_num];

	score_ptr = obj_ptr->score;
	if(score_ptr == NULL)
	    return(0);


        /*
         *      SWEXTCMD_SETSCORE format:
         *
         *	object_num 
	 *	credits rmu rmu_max damage_given damage_recieved
	 *	kills
         */
        sprintf(sndbuf,
"%i %i\
 %ld %.4lf %.4lf %.4lf %.4lf %.4lf %ld\n",
                CS_CODE_EXT,
                SWEXTCMD_SETSCORE,

                object_num,
                score_ptr->credits,
		score_ptr->rmu,
		score_ptr->rmu_max,
                score_ptr->damage_given,
                score_ptr->damage_recieved,
                score_ptr->kills
        );
        NetDoSend(condescriptor, sndbuf);


        return(0);
}