ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/info.c
(Generate patch)

Comparing deliantra/server/socket/info.c (file contents):
Revision 1.1.1.1 by root, Fri Feb 3 07:14:43 2006 UTC vs.
Revision 1.2 by root, Sat Mar 18 15:40:21 2006 UTC

1/* 1/*
2 * static char *rcsid_sock_info_c = 2 * static char *rcsid_sock_info_c =
3 * "$Id: info.c,v 1.1.1.1 2006/02/03 07:14:43 root Exp $"; 3 * "$Id: info.c,v 1.2 2006/03/18 15:40:21 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
88 * If pl is NULL or without contr set, writes message to log. 88 * If pl is NULL or without contr set, writes message to log.
89 * 89 *
90 * Else sends message to player via esrv_print_msg 90 * Else sends message to player via esrv_print_msg
91 */ 91 */
92 92
93static void print_message(int colr, object *pl,const char *tmp) { 93static void print_message(int colr, const object *pl, const char *tmp) {
94 94
95 if(tmp == (char *) NULL) { 95 if(tmp == (char *) NULL) {
96 tmp="[NULL]"; 96 tmp="[NULL]";
97 } 97 }
98 98
110/** 110/**
111 * Prints out the contents of specified buffer structures, 111 * Prints out the contents of specified buffer structures,
112 * and clears the string. 112 * and clears the string.
113 */ 113 */
114 114
115void flush_output_element(object *pl, Output_Buf *outputs) 115void flush_output_element(const object *pl, Output_Buf *outputs)
116{ 116{
117 char tbuf[MAX_BUF]; 117 char tbuf[MAX_BUF];
118 118
119 if (outputs->buf==NULL) return; 119 if (outputs->buf==NULL) return;
120 if (outputs->count > 1) {
120 snprintf(tbuf,MAX_BUF, "%d times %s", outputs->count, outputs->buf); 121 snprintf(tbuf,MAX_BUF, "%d times %s", outputs->count, outputs->buf);
121 print_message(NDI_BLACK, pl, tbuf); 122 print_message(NDI_BLACK, pl, tbuf);
123 } else
124 print_message(NDI_BLACK, pl, outputs->buf);
125
122 free_string(outputs->buf); 126 free_string(outputs->buf);
123 outputs->buf=NULL; 127 outputs->buf=NULL;
124 outputs->first_update=0; /* This way, it will be reused */ 128 outputs->first_update=0; /* This way, it will be reused */
125} 129}
126 130
137 * 141 *
138 * If message not already in buffers, flushes olders buffer, 142 * If message not already in buffers, flushes olders buffer,
139 * and adds message to queue. 143 * and adds message to queue.
140 */ 144 */
141 145
142void check_output_buffers(object *pl, const char *buf) 146static void check_output_buffers(const object *pl, const char *buf)
143{ 147{
144 int i, oldest=0; 148 int i, oldest=0;
145 149
146 if (pl->contr->outputs_count<2) { 150 if (pl->contr->outputs_count<2) {
147 print_message(NDI_BLACK, pl, buf); 151 print_message(NDI_BLACK, pl, buf);
192 * 196 *
193 * If message is black, and not NDI_UNIQUE, gets sent through output buffers. 197 * If message is black, and not NDI_UNIQUE, gets sent through output buffers.
194 * 198 *
195 */ 199 */
196 200
197void new_draw_info(int flags,int pri, object *pl, const char *buf) 201void new_draw_info(int flags, int pri, const object *pl, const char *buf)
198{ 202{
199 203
200 if (flags & NDI_ALL) { 204 if (flags & NDI_ALL) {
201 player *tmppl; 205 player *tmppl;
202 int i; 206 int i;
238 * formatting, so instead of the calling function having to do it, we do 242 * formatting, so instead of the calling function having to do it, we do
239 * it here. It may also have advantages in the future for reduction of 243 * it here. It may also have advantages in the future for reduction of
240 * client/server bandwidth (client could keep track of various strings 244 * client/server bandwidth (client could keep track of various strings
241 */ 245 */
242 246
243void new_draw_info_format(int flags, int pri,object *pl, const char *format, ...) 247void new_draw_info_format(int flags, int pri, const object *pl, const char *format, ...)
244{ 248{
245 char buf[HUGE_BUF]; 249 char buf[HUGE_BUF];
246 250
247 va_list ap; 251 va_list ap;
248 va_start(ap, format); 252 va_start(ap, format);
254 new_draw_info(flags, pri, pl, buf); 258 new_draw_info(flags, pri, pl, buf);
255} 259}
256 260
257 261
258void draw_ext_info( 262void draw_ext_info(
259 int flags, int pri, object *pl, uint8 type, 263 int flags, int pri, const object *pl, uint8 type,
260 uint8 subtype, const char* message, const char* oldmessage){ 264 uint8 subtype, const char* message, const char* oldmessage){
261 265
262 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL)) 266 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL))
263 return; 267 return;
264 268
277 esrv_print_ext_msg(&pl->contr->socket,flags&NDI_COLOR_MASK,type,subtype,message); 281 esrv_print_ext_msg(&pl->contr->socket,flags&NDI_COLOR_MASK,type,subtype,message);
278 } 282 }
279} 283}
280 284
281void draw_ext_info_format( 285void draw_ext_info_format(
282 int flags, int pri, object *pl, uint8 type, 286 int flags, int pri, const object *pl, uint8 type,
283 uint8 subtype, const char* old_format, 287 uint8 subtype, const char* old_format,
284 char* new_format, ...){ 288 char* new_format, ...){
285 289
286 char buf[HUGE_BUF]; 290 char buf[HUGE_BUF];
287 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL)) 291 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines