File: clientlb.c

package info (click to toggle)
conquest 8.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,984 kB
  • ctags: 3,086
  • sloc: ansic: 39,393; sh: 8,540; yacc: 446; makefile: 296; lex: 146
file content (93 lines) | stat: -rw-r--r-- 2,253 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
#include "c_defs.h"

/************************************************************************
 *
 * client specific stuff
 *
 * $Id: clientlb.c,v 1.5 2004/05/08 21:01:41 jon Exp $
 *
 * Copyright 2003 Jon Trulson under the ARTISTIC LICENSE. (See LICENSE).
 ***********************************************************************/

#include "global.h"
#include "conf.h"
#include "conqnet.h"
#include "protocol.h"
#include "packet.h"
#include "client.h"
#include "clientlb.h"
#include "conqcom.h"
#include "context.h"
#include "record.h"
#include "disputil.h"


/* put a recieved message into the clinet's copy of the message buffer
   (Msgs[]).  Pretty much a copy of clbStoreMsg() without the locking */
void clntStoreMessage(spMessage_t *msg)
{
  int nlastmsg;

  if (!msg)
    return;

  nlastmsg = modp1( ConqInfo->lastmsg + 1, MAXMESSAGES );
  strncpy(Msgs[nlastmsg].msgbuf, msg->msg, MESSAGE_SIZE);
  Msgs[nlastmsg].msgfrom = (int)((Sgn16)ntohs(msg->from));
  Msgs[nlastmsg].msgto = (int)((Sgn16)ntohs(msg->to));
  Msgs[nlastmsg].flags = msg->flags;
  ConqInfo->lastmsg = nlastmsg;

  /* Remove allowable last message restrictions. */
  Ships[Context.snum].alastmsg = LMSG_READALL;

  return;
}


/* feedback messages are sent by the server using spMessage_t's like
   normal messages.  However, these messages are displayed immediately,
   as well as being displayed on MSG_LIN1 */
void clntDisplayFeedback(char *msg)
{
  if (!msg)
    return;

  displayFeedback(msg, MSG_LIN1);

  return;
}

/* return a static string containing the server's stringified  flags */
char *clntServerFlagsStr(Unsgn32 flags)
{
  static char serverflags[256];

  if (flags == SPSSTAT_FLAGS_NONE)
    strcpy(serverflags, "None");
  else
    strcpy(serverflags, "");

  if (flags & SPSSTAT_FLAGS_REFIT)
    strcat(serverflags, "Refit ");
  
  if (flags & SPSSTAT_FLAGS_VACANT)
    strcat(serverflags, "Vacant ");
  
  if (flags & SPSSTAT_FLAGS_SLINGSHOT)
    strcat(serverflags, "SlingShot ");
  
  if (flags & SPSSTAT_FLAGS_NODOOMSDAY)
    strcat(serverflags, "NoDoomsday ");
  
  if (flags & SPSSTAT_FLAGS_KILLBOTS)
    strcat(serverflags, "Killbots ");
  
  if (flags & SPSSTAT_FLAGS_SWITCHTEAM)
    strcat(serverflags, "SwitchTeam ");

  return serverflags;
}