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 by elmex, Sun Aug 13 17:16:05 2006 UTC vs.
Revision 1.4 by root, Sun Sep 3 00:18:43 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 2006/08/13 17:16:05 elmex Exp $"; 3 * "$Id: info.C,v 1.4 2006/09/03 00:18:43 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
51static void esrv_print_msg(NewSocket *ns,int color, const char *str) 51static void esrv_print_msg(NewSocket *ns,int color, const char *str)
52{ 52{
53 char buf[HUGE_BUF]; 53 char buf[HUGE_BUF];
54 54
55 if (ns->status == Ns_Old) { 55 if (ns->status == Ns_Old) {
56 snprintf(buf,HUGE_BUF,"%s\n", str); 56 snprintf(buf,HUGE_BUF,"%s\n", str);
57 } else { 57 } else {
58 snprintf(buf,HUGE_BUF, "drawinfo %d %s", color, str); 58 snprintf(buf,HUGE_BUF, "drawinfo %d %s", color, str);
59 } 59 }
60/* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/ 60/* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/
61 Write_String_To_Socket(ns, buf, strlen(buf)); 61 Write_String_To_Socket(ns, buf, strlen(buf));
62} 62}
63 63
72 */ 72 */
73static void esrv_print_ext_msg(NewSocket *ns,int color,uint8 type, uint8 subtype, const char *message) 73static void esrv_print_ext_msg(NewSocket *ns,int color,uint8 type, uint8 subtype, const char *message)
74{ 74{
75 char buf[HUGE_BUF]; 75 char buf[HUGE_BUF];
76 snprintf(buf,HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); 76 snprintf(buf,HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message);
77 Write_String_To_Socket(ns, buf, strlen(buf)); 77 Write_String_To_Socket(ns, buf, strlen(buf));
78/* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/ 78/* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/
79 79
80} 80}
81 81
82/** 82/**
115{ 115{
116 char tbuf[MAX_BUF]; 116 char tbuf[MAX_BUF];
117 117
118 if (outputs->buf==NULL) return; 118 if (outputs->buf==NULL) return;
119 if (outputs->count > 1) { 119 if (outputs->count > 1) {
120 snprintf(tbuf,MAX_BUF, "%d times %s", outputs->count, outputs->buf); 120 snprintf(tbuf,MAX_BUF, "%d times %s", outputs->count, &outputs->buf);
121 print_message(NDI_BLACK, pl, tbuf); 121 print_message(NDI_BLACK, pl, tbuf);
122 } else 122 } else
123 print_message(NDI_BLACK, pl, outputs->buf); 123 print_message(NDI_BLACK, pl, &outputs->buf);
124 124
125 free_string(outputs->buf);
126 outputs->buf=NULL; 125 outputs->buf=NULL;
127 outputs->first_update=0; /* This way, it will be reused */ 126 outputs->first_update=0; /* This way, it will be reused */
128} 127}
129 128
130/** 129/**
145static void check_output_buffers(const object *pl, const char *buf) 144static void check_output_buffers(const object *pl, const char *buf)
146{ 145{
147 int i, oldest=0; 146 int i, oldest=0;
148 147
149 if (pl->contr->outputs_count<2) { 148 if (pl->contr->outputs_count<2) {
150 print_message(NDI_BLACK, pl, buf); 149 print_message(NDI_BLACK, pl, buf);
151 return; 150 return;
152 } 151 }
153 else { 152 else {
154 for (i=0; i<NUM_OUTPUT_BUFS; i++) { 153 for (i=0; i<NUM_OUTPUT_BUFS; i++) {
155 if (pl->contr->outputs[i].buf && 154 if (pl->contr->outputs[i].buf &&
156 !strcmp(buf, pl->contr->outputs[i].buf)) break; 155 !strcmp(buf, pl->contr->outputs[i].buf)) break;
157 else if (pl->contr->outputs[i].first_update < 156 else if (pl->contr->outputs[i].first_update <
158 pl->contr->outputs[oldest].first_update) 157 pl->contr->outputs[oldest].first_update)
159 oldest=i; 158 oldest=i;
160 } 159 }
161 /* We found a match */ 160 /* We found a match */
162 if (i<NUM_OUTPUT_BUFS) { 161 if (i<NUM_OUTPUT_BUFS) {
163 pl->contr->outputs[i].count++; 162 pl->contr->outputs[i].count++;
164 if (pl->contr->outputs[i].count>=pl->contr->outputs_count) { 163 if (pl->contr->outputs[i].count>=pl->contr->outputs_count) {
165 flush_output_element(pl, &pl->contr->outputs[i]); 164 flush_output_element(pl, &pl->contr->outputs[i]);
166 } 165 }
167 } 166 }
168 /* No match - flush the oldest, and put the new one in */ 167 /* No match - flush the oldest, and put the new one in */
169 else { 168 else {
170 flush_output_element(pl, &pl->contr->outputs[oldest]); 169 flush_output_element(pl, &pl->contr->outputs[oldest]);
171 170
172 pl->contr->outputs[oldest].first_update = pticks; 171 pl->contr->outputs[oldest].first_update = pticks;
173 pl->contr->outputs[oldest].count = 1; 172 pl->contr->outputs[oldest].count = 1;
174 if (pl->contr->outputs[oldest].buf!=NULL)
175 free_string(pl->contr->outputs[oldest].buf);
176 pl->contr->outputs[oldest].buf = add_string(buf); 173 pl->contr->outputs[oldest].buf = buf;
177 } 174 }
178 } 175 }
179} 176}
180 177
181 178
182 179
183/** 180/**
184 * Sends message to player(s). 181 * Sends message to player(s).
185 * 182 *
199 196
200void new_draw_info(int flags, int pri, const object *pl, const char *buf) 197void new_draw_info(int flags, int pri, const object *pl, const char *buf)
201{ 198{
202 199
203 if (flags & NDI_ALL) { 200 if (flags & NDI_ALL) {
204 player *tmppl; 201 player *tmppl;
205 int i; 202 int i;
206 203
207 for (tmppl=first_player; tmppl!=NULL; tmppl=tmppl->next) 204 for (tmppl=first_player; tmppl!=NULL; tmppl=tmppl->next)
208 new_draw_info((flags & ~NDI_ALL), pri, tmppl->ob, buf); 205 new_draw_info((flags & ~NDI_ALL), pri, tmppl->ob, buf);
209 206
210 for (i=1; i<socket_info.allocated_sockets; i++) { 207 for (i=1; i<socket_info.allocated_sockets; i++) {
211 if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri< 10) { 208 if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri< 10) {
212 cs_write_string(&init_sockets[i], buf, strlen(buf)); 209 cs_write_string(&init_sockets[i], buf, strlen(buf));
213 /* Most messages don't have a newline, so add one */ 210 /* Most messages don't have a newline, so add one */
214 cs_write_string(&init_sockets[i], "\n", 1); 211 cs_write_string(&init_sockets[i], "\n", 1);
215 } 212 }
216 } 213 }
217 214
218 return; 215 return;
219 } 216 }
220 if(!pl || (pl->type==PLAYER && pl->contr==NULL)) { 217 if(!pl || (pl->type==PLAYER && pl->contr==NULL)) {
221 /* Write to the socket? */ 218 /* Write to the socket? */
222 print_message(0, NULL, buf); 219 print_message(0, NULL, buf);
223 return; 220 return;
224 } 221 }
225 if (pl->type!=PLAYER) return; 222 if (pl->type!=PLAYER) return;
226 if (pri>=pl->contr->listening) return; 223 if (pri>=pl->contr->listening) return;
227 224
228 if ((flags&NDI_COLOR_MASK)==NDI_BLACK && !(flags &NDI_UNIQUE)) { 225 if ((flags&NDI_COLOR_MASK)==NDI_BLACK && !(flags &NDI_UNIQUE)) {
229 /* following prints stuff out, as appropriate */ 226 /* following prints stuff out, as appropriate */
230 check_output_buffers(pl, buf); 227 check_output_buffers(pl, buf);
231 } 228 }
232 else { 229 else {
233 print_message(flags&NDI_COLOR_MASK, pl, buf); 230 print_message(flags&NDI_COLOR_MASK, pl, buf);
234 } 231 }
235} 232}
236 233
237/** 234/**
238 * Wrapper for new_draw_info printf-like. 235 * Wrapper for new_draw_info printf-like.
285 int flags, int pri, const object *pl, uint8 type, 282 int flags, int pri, const object *pl, uint8 type,
286 uint8 subtype, const char* old_format, 283 uint8 subtype, const char* old_format,
287 char* new_format, ...){ 284 char* new_format, ...){
288 285
289 char buf[HUGE_BUF]; 286 char buf[HUGE_BUF];
290 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL)) 287 if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL))
291 return; 288 return;
292 289
293 if (pri>=pl->contr->listening) return; 290 if (pri>=pl->contr->listening) return;
294 if (!CLIENT_SUPPORT_READABLES(&pl->contr->socket,type)){ 291 if (!CLIENT_SUPPORT_READABLES(&pl->contr->socket,type)){
295 va_list ap; 292 va_list ap;
296 LOG(llevDebug,"Non supported extension text type for client.\n"); 293 LOG(llevDebug,"Non supported extension text type for client.\n");
297 va_start(ap, new_format); 294 va_start(ap, new_format);
298 vsnprintf(buf, HUGE_BUF, old_format, ap); 295 vsnprintf(buf, HUGE_BUF, old_format, ap);
299 va_end(ap); 296 va_end(ap);
300 new_draw_info(flags, pri, pl, buf); 297 new_draw_info(flags, pri, pl, buf);
301 return; 298 return;
302 }else{ 299 }else{
303 va_list ap; 300 va_list ap;
304 va_start(ap, new_format); 301 va_start(ap, new_format);
305 vsnprintf(buf, HUGE_BUF, new_format, ap); 302 vsnprintf(buf, HUGE_BUF, new_format, ap);
306 va_end(ap); 303 va_end(ap);
307 strip_media_tag(buf); 304 strip_media_tag(buf);
314 311
315void new_info_map_except(int color, mapstruct *map, object *op, const char *str) { 312void new_info_map_except(int color, mapstruct *map, object *op, const char *str) {
316 player *pl; 313 player *pl;
317 314
318 for(pl = first_player; pl != NULL; pl = pl->next) 315 for(pl = first_player; pl != NULL; pl = pl->next)
319 if(pl->ob != NULL && pl->ob->map == map && pl->ob != op) { 316 if(pl->ob != NULL && pl->ob->map == map && pl->ob != op) {
320 new_draw_info(color, 0, pl->ob, str); 317 new_draw_info(color, 0, pl->ob, str);
321 } 318 }
322} 319}
323 320
324/** 321/**
325 * Writes to everyone on the map except op1 and op2 322 * Writes to everyone on the map except op1 and op2
326 */ 323 */
327 324
328void new_info_map_except2(int color, mapstruct *map, object *op1, object *op2, 325void new_info_map_except2(int color, mapstruct *map, object *op1, object *op2,
329 const char *str) { 326 const char *str) {
330 player *pl; 327 player *pl;
331 328
332 for(pl = first_player; pl != NULL; pl = pl->next) 329 for(pl = first_player; pl != NULL; pl = pl->next)
333 if(pl->ob != NULL && pl->ob->map == map 330 if(pl->ob != NULL && pl->ob->map == map
334 && pl->ob != op1 && pl->ob != op2) { 331 && pl->ob != op1 && pl->ob != op2) {
335 new_draw_info(color, 0, pl->ob, str); 332 new_draw_info(color, 0, pl->ob, str);
336 } 333 }
337} 334}
338 335
339/** 336/**
340 * Writes to everyone on the specified map 337 * Writes to everyone on the specified map
341 */ 338 */
342 339
343void new_info_map(int color, mapstruct *map, const char *str) { 340void new_info_map(int color, mapstruct *map, const char *str) {
344 player *pl; 341 player *pl;
345 342
346 for(pl = first_player; pl != NULL; pl = pl->next) 343 for(pl = first_player; pl != NULL; pl = pl->next)
347 if(pl->ob != NULL && pl->ob->map == map) { 344 if(pl->ob != NULL && pl->ob->map == map) {
348 new_draw_info(color, 0, pl->ob, str); 345 new_draw_info(color, 0, pl->ob, str);
349 } 346 }
350} 347}
351 348
352 349
353/** 350/**
354 * This does nothing now. However, in theory, we should probably send 351 * This does nothing now. However, in theory, we should probably send
363 * Get player's current range attack in obuf. 360 * Get player's current range attack in obuf.
364 */ 361 */
365void rangetostring(object *pl,char *obuf) 362void rangetostring(object *pl,char *obuf)
366{ 363{
367 switch(pl->contr->shoottype) { 364 switch(pl->contr->shoottype) {
368 case range_none: 365 case range_none:
369 strcpy(obuf,"Range: nothing"); 366 strcpy(obuf,"Range: nothing");
370 break; 367 break;
371 368
372 case range_bow: 369 case range_bow:
373 { 370 {
374 object *op; 371 object *op;
375 372
376 for (op = pl->inv; op; op=op->below) 373 for (op = pl->inv; op; op=op->below)
377 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) 374 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED))
378 break; 375 break;
379 if(op==NULL) break; 376 if(op==NULL) break;
380 377
381 sprintf (obuf, "Range: %s (%s)", query_base_name(op, 0), 378 sprintf (obuf, "Range: %s (%s)", query_base_name(op, 0),
382 op->race ? op->race : "nothing"); 379 op->race ? (const char *)op->race : "nothing");
383 } 380 }
384 break; 381 break;
385 382
386 case range_magic: 383 case range_magic:
387 if (settings.casting_time == TRUE) { 384 if (settings.casting_time == TRUE) {
388 if (pl->casting_time > -1) { 385 if (pl->casting_time > -1) {
389 if (pl->casting_time == 0) 386 if (pl->casting_time == 0)
390 sprintf(obuf,"Range: Holding spell (%s)", 387 sprintf(obuf,"Range: Holding spell (%s)",
391 pl->spell->name); 388 (const char *)pl->spell->name);
392 else 389 else
393 sprintf(obuf,"Range: Casting spell (%s)", 390 sprintf(obuf,"Range: Casting spell (%s)",
394 pl->spell->name); 391 (const char *)pl->spell->name);
395 } else 392 } else
396 sprintf(obuf,"Range: spell (%s)", 393 sprintf(obuf,"Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
397 pl->contr->ranges[range_magic]->name); 394 } else
398 } else 395 sprintf(obuf,"Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
399 sprintf(obuf,"Range: spell (%s)", 396 break;
400 pl->contr->ranges[range_magic]->name);
401 break;
402 397
403 case range_misc: 398 case range_misc:
404 sprintf(obuf,"Range: %s", 399 sprintf(obuf,"Range: %s", pl->contr->ranges[range_misc] ?
405 pl->contr->ranges[range_misc]?
406 query_base_name(pl->contr->ranges[range_misc],0): "none"); 400 query_base_name(pl->contr->ranges[range_misc],0) : "none");
407 break; 401 break;
408 402
409 /* range_scroll is only used for controlling golems. If the 403 /* range_scroll is only used for controlling golems. If the
410 * the player does not have a golem, reset some things. 404 * the player does not have a golem, reset some things.
411 */ 405 */
412 case range_golem: 406 case range_golem:
413 if (pl->contr->ranges[range_golem]!=NULL) 407 if (pl->contr->ranges[range_golem]!=NULL)
414 sprintf(obuf,"Range: golem (%s)",pl->contr->ranges[range_golem]->name); 408 sprintf(obuf,"Range: golem (%s)", &pl->contr->ranges[range_golem]->name);
415 else { 409 else {
416 pl->contr->shoottype = range_none; 410 pl->contr->shoottype = range_none;
417 strcpy(obuf,"Range: nothing"); 411 strcpy(obuf,"Range: nothing");
418 } 412 }
419 break; 413 break;
420 414
421 case range_skill: 415 case range_skill:
422 sprintf(obuf,"Skill: %s", pl->chosen_skill!=NULL ? 416 sprintf(obuf,"Skill: %s", pl->chosen_skill!=NULL ?
423 pl->chosen_skill->name : "none"); 417 (const char *)pl->chosen_skill->name : "none");
424 break; 418 break;
425 419
426 case range_builder: 420 case range_builder:
427 sprintf( obuf, "Builder: %s", query_base_name( pl->contr->ranges[ range_builder ], 0 ) ); 421 sprintf( obuf, "Builder: %s", query_base_name( pl->contr->ranges[ range_builder ], 0 ) );
428 break; 422 break;
429 423
430 default: 424 default:
431 strcpy(obuf,"Range: illegal"); 425 strcpy(obuf,"Range: illegal");
432 } 426 }
433} 427}
434 428
435/** 429/**
436 * Sets player title. 430 * Sets player title.
437 */ 431 */
438void set_title(object *pl, char *buf) 432void set_title(object *pl, char *buf)
439{ 433{
440 /* Eneq(@csd.uu.se): Let players define their own titles. */ 434 /* Eneq(@csd.uu.se): Let players define their own titles. */
441 if (pl->contr->own_title[0]=='\0') 435 if (pl->contr->own_title[0]=='\0')
442 sprintf(buf,"Player: %s the %s",pl->name,pl->contr->title); 436 sprintf(buf,"Player: %s the %s",(const char *)pl->name,(const char *)pl->contr->title);
443 else 437 else
444 sprintf(buf,"Player: %s %s",pl->name,pl->contr->own_title); 438 sprintf(buf,"Player: %s %s",(const char *)pl->name,(const char *)pl->contr->own_title);
445} 439}
446 440
447 441
448/** 442/**
449 * Helper for magic map creation. 443 * Helper for magic map creation.
462 sint16 nx, ny; 456 sint16 nx, ny;
463 mapstruct *mp; 457 mapstruct *mp;
464 New_Face *f; 458 New_Face *f;
465 459
466 for (dx = -1; dx <= 1; dx++) { 460 for (dx = -1; dx <= 1; dx++) {
467 for (dy = -1; dy <= 1; dy++) { 461 for (dy = -1; dy <= 1; dy++) {
468 x = px + dx; 462 x = px + dx;
469 y = py + dy; 463 y = py + dy;
470 464
471 if (FABS(x) >= MAGIC_MAP_HALF || FABS(y) >= MAGIC_MAP_HALF) continue; 465 if (FABS(x) >= MAGIC_MAP_HALF || FABS(y) >= MAGIC_MAP_HALF) continue;
472 466
473 mp = pl->map; 467 mp = pl->map;
474 nx = pl->x + x; 468 nx = pl->x + x;
475 ny = pl->y + y; 469 ny = pl->y + y;
476 470
477 mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); 471 mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny);
478 if (mflags & P_OUT_OF_MAP) continue; 472 if (mflags & P_OUT_OF_MAP) continue;
479 473
480 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] == 0) { 474 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] == 0) {
481 f= GET_MAP_FACE(mp, nx, ny, 0);
482 if (f == blank_face)
483 f= GET_MAP_FACE(mp, nx, ny, 1); 475 f= GET_MAP_FACE(mp, nx, ny, 0);
484 if (f == blank_face) 476 if (f == blank_face)
477 f= GET_MAP_FACE(mp, nx, ny, 1);
478 if (f == blank_face)
485 f= GET_MAP_FACE(mp, nx, ny, 2); 479 f= GET_MAP_FACE(mp, nx, ny, 2);
486 480
487 /* Should probably have P_NO_MAGIC here also, but then shops don't 481 /* Should probably have P_NO_MAGIC here also, but then shops don't
488 * work. 482 * work.
489 */ 483 */
490 if (mflags & P_BLOCKSVIEW) 484 if (mflags & P_BLOCKSVIEW)
491 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); 485 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0);
492 else { 486 else {
493 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); 487 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0);
494 magic_mapping_mark_recursive(pl, map_mark, x, y); 488 magic_mapping_mark_recursive(pl, map_mark, x, y);
495 } 489 }
496 } 490 }
497 } 491 }
498 } 492 }
499} 493}
500 494
501 495
502/** 496/**
521 sint16 nx, ny; 515 sint16 nx, ny;
522 mapstruct *mp; 516 mapstruct *mp;
523 New_Face *f; 517 New_Face *f;
524 518
525 for (x = -strength; x <strength; x++) { 519 for (x = -strength; x <strength; x++) {
526 for (y = -strength; y <strength; y++) { 520 for (y = -strength; y <strength; y++) {
527 mp = pl->map; 521 mp = pl->map;
528 nx = pl->x + x; 522 nx = pl->x + x;
529 ny = pl->y + y; 523 ny = pl->y + y;
530 mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); 524 mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny);
531 if (mflags & P_OUT_OF_MAP) 525 if (mflags & P_OUT_OF_MAP)
532 continue; 526 continue;
533 else { 527 else {
534 f= GET_MAP_FACE(mp, nx, ny, 0);
535 if (f == blank_face)
536 f= GET_MAP_FACE(mp, nx, ny, 1); 528 f= GET_MAP_FACE(mp, nx, ny, 0);
537 if (f == blank_face) 529 if (f == blank_face)
530 f= GET_MAP_FACE(mp, nx, ny, 1);
531 if (f == blank_face)
538 f= GET_MAP_FACE(mp, nx, ny, 2); 532 f= GET_MAP_FACE(mp, nx, ny, 2);
539 } 533 }
540 534
541 if (mflags & P_BLOCKSVIEW) 535 if (mflags & P_BLOCKSVIEW)
542 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); 536 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0);
543 else { 537 else {
544 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); 538 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0);
545 magic_mapping_mark_recursive(pl, map_mark, x, y); 539 magic_mapping_mark_recursive(pl, map_mark, x, y);
546 } 540 }
547 } 541 }
548 } 542 }
549} 543}
550 544
551 545
552/** 546/**
564 char *map_mark = (char *) calloc(MAGIC_MAP_SIZE*MAGIC_MAP_SIZE, 1); 558 char *map_mark = (char *) calloc(MAGIC_MAP_SIZE*MAGIC_MAP_SIZE, 1);
565 int xmin, xmax, ymin, ymax; 559 int xmin, xmax, ymin, ymax;
566 SockList sl; 560 SockList sl;
567 561
568 if (pl->type!=PLAYER) { 562 if (pl->type!=PLAYER) {
569 LOG(llevError,"Non player object called draw_map.\n"); 563 LOG(llevError,"Non player object called draw_map.\n");
570 return; 564 return;
571 } 565 }
572 566
573 /* First, we figure out what spaces are 'reachable' by the player */ 567 /* First, we figure out what spaces are 'reachable' by the player */
574 magic_mapping_mark(pl, map_mark, 3); 568 magic_mapping_mark(pl, map_mark, 3);
575 569
581 xmin = MAGIC_MAP_SIZE; 575 xmin = MAGIC_MAP_SIZE;
582 ymin = MAGIC_MAP_SIZE; 576 ymin = MAGIC_MAP_SIZE;
583 xmax = 0; 577 xmax = 0;
584 ymax = 0; 578 ymax = 0;
585 for(x = 0; x < MAGIC_MAP_SIZE ; x++) { 579 for(x = 0; x < MAGIC_MAP_SIZE ; x++) {
586 for(y = 0; y < MAGIC_MAP_SIZE; y++) { 580 for(y = 0; y < MAGIC_MAP_SIZE; y++) {
587 if (map_mark[x + MAP_WIDTH(pl->map) * y] | FACE_FLOOR) { 581 if (map_mark[x + MAP_WIDTH(pl->map) * y] | FACE_FLOOR) {
588 xmin = x < xmin ? x : xmin; 582 xmin = x < xmin ? x : xmin;
589 xmax = x > xmax ? x : xmax; 583 xmax = x > xmax ? x : xmax;
590 ymin = y < ymin ? y : ymin; 584 ymin = y < ymin ? y : ymin;
591 ymax = y > ymax ? y : ymax; 585 ymax = y > ymax ? y : ymax;
592 } 586 }
593 } 587 }
594 } 588 }
595 589
596 sl.buf= (unsigned char*) malloc(MAXSOCKBUF); 590 sl.buf= (unsigned char*) malloc(MAXSOCKBUF);
597 snprintf((char*)sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax-xmin+1), (ymax-ymin+1), 591 snprintf((char*)sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax-xmin+1), (ymax-ymin+1),
598 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); 592 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin);
599 sl.len=strlen((char*)sl.buf); 593 sl.len=strlen((char*)sl.buf);
600 594
601 for (y = ymin; y <= ymax; y++) { 595 for (y = ymin; y <= ymax; y++) {
602 for (x = xmin; x <= xmax; x++) { 596 for (x = xmin; x <= xmax; x++) {
603 sl.buf[sl.len++]= map_mark[x+MAGIC_MAP_SIZE*y] & ~FACE_FLOOR; 597 sl.buf[sl.len++]= map_mark[x+MAGIC_MAP_SIZE*y] & ~FACE_FLOOR;
604 } /* x loop */ 598 } /* x loop */
605 } /* y loop */ 599 } /* y loop */
606 600
607 Send_With_Handling(&pl->contr->socket, &sl); 601 Send_With_Handling(&pl->contr->socket, &sl);
608 free(sl.buf); 602 free(sl.buf);
609 free(map_mark); 603 free(map_mark);
621 int i; 615 int i;
622 size_t len; 616 size_t len;
623 char buf[MAX_BUF]; 617 char buf[MAX_BUF];
624 618
625 if (With!=NULL) { 619 if (With!=NULL) {
626 snprintf(buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n",Who,What,WhatType,With,WithType); 620 snprintf(buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n",Who,What,WhatType,With,WithType);
627 } 621 }
628 else { 622 else {
629 snprintf(buf,MAX_BUF, "%s\t%s\t%d\n",Who,What,WhatType); 623 snprintf(buf,MAX_BUF, "%s\t%s\t%d\n",Who,What,WhatType);
630 } 624 }
631 len=strlen(buf); 625 len=strlen(buf);
632 for(i=1; i<socket_info.allocated_sockets; i++) { 626 for(i=1; i<socket_info.allocated_sockets; i++) {
633 if (init_sockets[i].old_mode == Old_Listen) { 627 if (init_sockets[i].old_mode == Old_Listen) {
634 cs_write_string(&init_sockets[i], buf, len); 628 cs_write_string(&init_sockets[i], buf, len);
635 } 629 }
636 } 630 }
637} 631}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines