File: netrefresh.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 (99 lines) | stat: -rw-r--r-- 2,555 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "swserv.h"



int NetHandleRefresh(int condescriptor, char *arg) 
{
	NetSendRefresh(condescriptor);

	return(0);
}


int NetSendRefresh(int condescriptor)
{
	long i;
        int weapon_num;
        long object_num;
        xsw_object_struct *obj_ptr, **ptr;


        /* Connection must be logged in. */
        if(!ConIsLoggedIn(condescriptor))  
            return(-1);


        /* Get object_num and obj_ptr. */
        object_num = connection[condescriptor]->object_num;
        if(DBIsObjectGarbage(object_num))
            return(-1);
        else
            obj_ptr = xsw_object[object_num];


	/* Send units. */
	NetSendUnits(condescriptor);

	/* Send data file names. */
        NetSendSetImageSet(condescriptor, unv_head.isr);
	NetSendSetSoundSet(condescriptor, unv_head.ss);
	NetSendSetOCSN(condescriptor, unv_head.ocsn);

        /* Send who am I. */
        NetSendWhoAmI(condescriptor);


        /* Go through XSW objects list. */
        for(i = 0, ptr = xsw_object;
            i < total_objects;
            i++, ptr++
        )
        {
            /* Check objects are valid and within range. */
            if(!Mu3DInRangePtr(obj_ptr, *ptr, obj_ptr->scanner_range))
                continue;

            /*   If object is not owned by the connection,
             *   then check the visibility of the object.
             */
            if((*ptr)->owner != object_num)
            {
                if(DBGetObjectVisibilityPtr(*ptr) <= 0.00)
                    continue;
            }

            /* Check if marked hidden from connection. */
            if((*ptr)->server_options & XSW_OBJF_HIDEFROMCON)
                continue;

	    /* Send create object. */
	    NetSendCreateObject(condescriptor, i);

            /* Send object maximums. */
            NetSendObjectMaximums(condescriptor, i);

            /* Send object sector position. */
            NetSendObjectName(condescriptor, i);

	    /* Engine state. */
	    NetSendSetEngine(condescriptor, i);

	    /* Com channel. */
	    NetSendSetChannel(condescriptor, i, (*ptr)->com_channel);


            /* If locked on, send weapons and current values. */
            if(i == obj_ptr->locked_on)
            {
                /* Send values. */
                NetSendObjectValues(condescriptor, i);
        
                /* Send weapon values. */
                for(weapon_num = 0; weapon_num < (*ptr)->total_weapons; weapon_num++)
                    NetSendWeaponValues(condescriptor, i, weapon_num);
            }
        }


        return(0);
}