--- deliantra/server/socket/info.C 2006/08/13 17:16:05 1.1 +++ deliantra/server/socket/info.C 2006/08/29 08:01:38 1.2 @@ -1,6 +1,6 @@ /* * static char *rcsid_sock_info_c = - * "$Id: info.C,v 1.1 2006/08/13 17:16:05 elmex Exp $"; + * "$Id: info.C,v 1.2 2006/08/29 08:01:38 root Exp $"; */ /* @@ -53,9 +53,9 @@ char buf[HUGE_BUF]; if (ns->status == Ns_Old) { - snprintf(buf,HUGE_BUF,"%s\n", str); + snprintf(buf,HUGE_BUF,"%s\n", str); } else { - snprintf(buf,HUGE_BUF, "drawinfo %d %s", color, str); + snprintf(buf,HUGE_BUF, "drawinfo %d %s", color, str); } /* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/ Write_String_To_Socket(ns, buf, strlen(buf)); @@ -74,7 +74,7 @@ { char buf[HUGE_BUF]; snprintf(buf,HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); - Write_String_To_Socket(ns, buf, strlen(buf)); + Write_String_To_Socket(ns, buf, strlen(buf)); /* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/ } @@ -147,37 +147,37 @@ int i, oldest=0; if (pl->contr->outputs_count<2) { - print_message(NDI_BLACK, pl, buf); - return; + print_message(NDI_BLACK, pl, buf); + return; } else { - for (i=0; icontr->outputs[i].buf && - !strcmp(buf, pl->contr->outputs[i].buf)) break; - else if (pl->contr->outputs[i].first_update < - pl->contr->outputs[oldest].first_update) - oldest=i; - } - /* We found a match */ - if (icontr->outputs[i].count++; - if (pl->contr->outputs[i].count>=pl->contr->outputs_count) { - flush_output_element(pl, &pl->contr->outputs[i]); - } - } - /* No match - flush the oldest, and put the new one in */ - else { - flush_output_element(pl, &pl->contr->outputs[oldest]); - - pl->contr->outputs[oldest].first_update = pticks; - pl->contr->outputs[oldest].count = 1; - if (pl->contr->outputs[oldest].buf!=NULL) - free_string(pl->contr->outputs[oldest].buf); - pl->contr->outputs[oldest].buf = add_string(buf); - } + for (i=0; icontr->outputs[i].buf && + !strcmp(buf, pl->contr->outputs[i].buf)) break; + else if (pl->contr->outputs[i].first_update < + pl->contr->outputs[oldest].first_update) + oldest=i; + } + /* We found a match */ + if (icontr->outputs[i].count++; + if (pl->contr->outputs[i].count>=pl->contr->outputs_count) { + flush_output_element(pl, &pl->contr->outputs[i]); + } + } + /* No match - flush the oldest, and put the new one in */ + else { + flush_output_element(pl, &pl->contr->outputs[oldest]); + + pl->contr->outputs[oldest].first_update = pticks; + pl->contr->outputs[oldest].count = 1; + if (pl->contr->outputs[oldest].buf!=NULL) + free_string(pl->contr->outputs[oldest].buf); + pl->contr->outputs[oldest].buf = add_string(buf); + } } } - + /** @@ -201,36 +201,36 @@ { if (flags & NDI_ALL) { - player *tmppl; - int i; + player *tmppl; + int i; - for (tmppl=first_player; tmppl!=NULL; tmppl=tmppl->next) - new_draw_info((flags & ~NDI_ALL), pri, tmppl->ob, buf); + for (tmppl=first_player; tmppl!=NULL; tmppl=tmppl->next) + new_draw_info((flags & ~NDI_ALL), pri, tmppl->ob, buf); - for (i=1; itype==PLAYER && pl->contr==NULL)) { - /* Write to the socket? */ - print_message(0, NULL, buf); - return; + /* Write to the socket? */ + print_message(0, NULL, buf); + return; } if (pl->type!=PLAYER) return; if (pri>=pl->contr->listening) return; if ((flags&NDI_COLOR_MASK)==NDI_BLACK && !(flags &NDI_UNIQUE)) { - /* following prints stuff out, as appropriate */ - check_output_buffers(pl, buf); + /* following prints stuff out, as appropriate */ + check_output_buffers(pl, buf); } else { - print_message(flags&NDI_COLOR_MASK, pl, buf); + print_message(flags&NDI_COLOR_MASK, pl, buf); } } @@ -287,19 +287,19 @@ char* new_format, ...){ char buf[HUGE_BUF]; - if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL)) - return; - + if(!pl || (pl->type!=PLAYER) || (pl->contr==NULL)) + return; + if (pri>=pl->contr->listening) return; - if (!CLIENT_SUPPORT_READABLES(&pl->contr->socket,type)){ + if (!CLIENT_SUPPORT_READABLES(&pl->contr->socket,type)){ va_list ap; LOG(llevDebug,"Non supported extension text type for client.\n"); va_start(ap, new_format); vsnprintf(buf, HUGE_BUF, old_format, ap); va_end(ap); new_draw_info(flags, pri, pl, buf); - return; - }else{ + return; + }else{ va_list ap; va_start(ap, new_format); vsnprintf(buf, HUGE_BUF, new_format, ap); @@ -316,9 +316,9 @@ player *pl; for(pl = first_player; pl != NULL; pl = pl->next) - if(pl->ob != NULL && pl->ob->map == map && pl->ob != op) { - new_draw_info(color, 0, pl->ob, str); - } + if(pl->ob != NULL && pl->ob->map == map && pl->ob != op) { + new_draw_info(color, 0, pl->ob, str); + } } /** @@ -326,14 +326,14 @@ */ void new_info_map_except2(int color, mapstruct *map, object *op1, object *op2, - const char *str) { + const char *str) { player *pl; for(pl = first_player; pl != NULL; pl = pl->next) - if(pl->ob != NULL && pl->ob->map == map - && pl->ob != op1 && pl->ob != op2) { - new_draw_info(color, 0, pl->ob, str); - } + if(pl->ob != NULL && pl->ob->map == map + && pl->ob != op1 && pl->ob != op2) { + new_draw_info(color, 0, pl->ob, str); + } } /** @@ -344,9 +344,9 @@ player *pl; for(pl = first_player; pl != NULL; pl = pl->next) - if(pl->ob != NULL && pl->ob->map == map) { - new_draw_info(color, 0, pl->ob, str); - } + if(pl->ob != NULL && pl->ob->map == map) { + new_draw_info(color, 0, pl->ob, str); + } } @@ -365,70 +365,70 @@ void rangetostring(object *pl,char *obuf) { switch(pl->contr->shoottype) { - case range_none: - strcpy(obuf,"Range: nothing"); - break; - - case range_bow: - { - object *op; - - for (op = pl->inv; op; op=op->below) - if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) - break; - if(op==NULL) break; - - sprintf (obuf, "Range: %s (%s)", query_base_name(op, 0), - op->race ? op->race : "nothing"); - } - break; - - case range_magic: - if (settings.casting_time == TRUE) { - if (pl->casting_time > -1) { - if (pl->casting_time == 0) - sprintf(obuf,"Range: Holding spell (%s)", - pl->spell->name); - else - sprintf(obuf,"Range: Casting spell (%s)", - pl->spell->name); - } else - sprintf(obuf,"Range: spell (%s)", - pl->contr->ranges[range_magic]->name); - } else - sprintf(obuf,"Range: spell (%s)", - pl->contr->ranges[range_magic]->name); - break; - - case range_misc: - sprintf(obuf,"Range: %s", - pl->contr->ranges[range_misc]? - query_base_name(pl->contr->ranges[range_misc],0): "none"); - break; - - /* range_scroll is only used for controlling golems. If the - * the player does not have a golem, reset some things. - */ - case range_golem: - if (pl->contr->ranges[range_golem]!=NULL) - sprintf(obuf,"Range: golem (%s)",pl->contr->ranges[range_golem]->name); - else { - pl->contr->shoottype = range_none; - strcpy(obuf,"Range: nothing"); - } - break; - - case range_skill: - sprintf(obuf,"Skill: %s", pl->chosen_skill!=NULL ? - pl->chosen_skill->name : "none"); - break; + case range_none: + strcpy(obuf,"Range: nothing"); + break; + + case range_bow: + { + object *op; + + for (op = pl->inv; op; op=op->below) + if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) + break; + if(op==NULL) break; + + sprintf (obuf, "Range: %s (%s)", query_base_name(op, 0), + op->race ? op->race : "nothing"); + } + break; + + case range_magic: + if (settings.casting_time == TRUE) { + if (pl->casting_time > -1) { + if (pl->casting_time == 0) + sprintf(obuf,"Range: Holding spell (%s)", + pl->spell->name); + else + sprintf(obuf,"Range: Casting spell (%s)", + pl->spell->name); + } else + sprintf(obuf,"Range: spell (%s)", + pl->contr->ranges[range_magic]->name); + } else + sprintf(obuf,"Range: spell (%s)", + pl->contr->ranges[range_magic]->name); + break; + + case range_misc: + sprintf(obuf,"Range: %s", + pl->contr->ranges[range_misc]? + query_base_name(pl->contr->ranges[range_misc],0): "none"); + break; + + /* range_scroll is only used for controlling golems. If the + * the player does not have a golem, reset some things. + */ + case range_golem: + if (pl->contr->ranges[range_golem]!=NULL) + sprintf(obuf,"Range: golem (%s)",pl->contr->ranges[range_golem]->name); + else { + pl->contr->shoottype = range_none; + strcpy(obuf,"Range: nothing"); + } + break; + + case range_skill: + sprintf(obuf,"Skill: %s", pl->chosen_skill!=NULL ? + pl->chosen_skill->name : "none"); + break; case range_builder: sprintf( obuf, "Builder: %s", query_base_name( pl->contr->ranges[ range_builder ], 0 ) ); break; - default: - strcpy(obuf,"Range: illegal"); + default: + strcpy(obuf,"Range: illegal"); } } @@ -439,9 +439,9 @@ { /* Eneq(@csd.uu.se): Let players define their own titles. */ if (pl->contr->own_title[0]=='\0') - sprintf(buf,"Player: %s the %s",pl->name,pl->contr->title); + sprintf(buf,"Player: %s the %s",pl->name,pl->contr->title); else - sprintf(buf,"Player: %s %s",pl->name,pl->contr->own_title); + sprintf(buf,"Player: %s %s",pl->name,pl->contr->own_title); } @@ -464,37 +464,37 @@ New_Face *f; for (dx = -1; dx <= 1; dx++) { - for (dy = -1; dy <= 1; dy++) { - x = px + dx; - y = py + dy; - - if (FABS(x) >= MAGIC_MAP_HALF || FABS(y) >= MAGIC_MAP_HALF) continue; - - mp = pl->map; - nx = pl->x + x; - ny = pl->y + y; - - mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); - if (mflags & P_OUT_OF_MAP) continue; - - if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] == 0) { - f= GET_MAP_FACE(mp, nx, ny, 0); - if (f == blank_face) - f= GET_MAP_FACE(mp, nx, ny, 1); - if (f == blank_face) - f= GET_MAP_FACE(mp, nx, ny, 2); - - /* Should probably have P_NO_MAGIC here also, but then shops don't - * work. - */ - if (mflags & P_BLOCKSVIEW) - map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); - else { - map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); - magic_mapping_mark_recursive(pl, map_mark, x, y); - } - } - } + for (dy = -1; dy <= 1; dy++) { + x = px + dx; + y = py + dy; + + if (FABS(x) >= MAGIC_MAP_HALF || FABS(y) >= MAGIC_MAP_HALF) continue; + + mp = pl->map; + nx = pl->x + x; + ny = pl->y + y; + + mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); + if (mflags & P_OUT_OF_MAP) continue; + + if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] == 0) { + f= GET_MAP_FACE(mp, nx, ny, 0); + if (f == blank_face) + f= GET_MAP_FACE(mp, nx, ny, 1); + if (f == blank_face) + f= GET_MAP_FACE(mp, nx, ny, 2); + + /* Should probably have P_NO_MAGIC here also, but then shops don't + * work. + */ + if (mflags & P_BLOCKSVIEW) + map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); + else { + map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); + magic_mapping_mark_recursive(pl, map_mark, x, y); + } + } + } } } @@ -523,28 +523,28 @@ New_Face *f; for (x = -strength; x map; - nx = pl->x + x; - ny = pl->y + y; - mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); - if (mflags & P_OUT_OF_MAP) - continue; - else { - f= GET_MAP_FACE(mp, nx, ny, 0); - if (f == blank_face) - f= GET_MAP_FACE(mp, nx, ny, 1); - if (f == blank_face) - f= GET_MAP_FACE(mp, nx, ny, 2); - } - - if (mflags & P_BLOCKSVIEW) - map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); - else { - map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); - magic_mapping_mark_recursive(pl, map_mark, x, y); - } - } + for (y = -strength; y map; + nx = pl->x + x; + ny = pl->y + y; + mflags = get_map_flags(pl->map, &mp, nx, ny, &nx, &ny); + if (mflags & P_OUT_OF_MAP) + continue; + else { + f= GET_MAP_FACE(mp, nx, ny, 0); + if (f == blank_face) + f= GET_MAP_FACE(mp, nx, ny, 1); + if (f == blank_face) + f= GET_MAP_FACE(mp, nx, ny, 2); + } + + if (mflags & P_BLOCKSVIEW) + map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_WALL | (f?f->magicmap:0); + else { + map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE* (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f?f->magicmap:0); + magic_mapping_mark_recursive(pl, map_mark, x, y); + } + } } } @@ -566,8 +566,8 @@ SockList sl; if (pl->type!=PLAYER) { - LOG(llevError,"Non player object called draw_map.\n"); - return; + LOG(llevError,"Non player object called draw_map.\n"); + return; } /* First, we figure out what spaces are 'reachable' by the player */ @@ -583,25 +583,25 @@ xmax = 0; ymax = 0; for(x = 0; x < MAGIC_MAP_SIZE ; x++) { - for(y = 0; y < MAGIC_MAP_SIZE; y++) { - if (map_mark[x + MAP_WIDTH(pl->map) * y] | FACE_FLOOR) { - xmin = x < xmin ? x : xmin; - xmax = x > xmax ? x : xmax; - ymin = y < ymin ? y : ymin; - ymax = y > ymax ? y : ymax; - } - } + for(y = 0; y < MAGIC_MAP_SIZE; y++) { + if (map_mark[x + MAP_WIDTH(pl->map) * y] | FACE_FLOOR) { + xmin = x < xmin ? x : xmin; + xmax = x > xmax ? x : xmax; + ymin = y < ymin ? y : ymin; + ymax = y > ymax ? y : ymax; + } + } } sl.buf= (unsigned char*) malloc(MAXSOCKBUF); snprintf((char*)sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax-xmin+1), (ymax-ymin+1), - MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); + MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); sl.len=strlen((char*)sl.buf); for (y = ymin; y <= ymax; y++) { - for (x = xmin; x <= xmax; x++) { - sl.buf[sl.len++]= map_mark[x+MAGIC_MAP_SIZE*y] & ~FACE_FLOOR; - } /* x loop */ + for (x = xmin; x <= xmax; x++) { + sl.buf[sl.len++]= map_mark[x+MAGIC_MAP_SIZE*y] & ~FACE_FLOOR; + } /* x loop */ } /* y loop */ Send_With_Handling(&pl->contr->socket, &sl); @@ -623,15 +623,15 @@ char buf[MAX_BUF]; if (With!=NULL) { - snprintf(buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n",Who,What,WhatType,With,WithType); + snprintf(buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n",Who,What,WhatType,With,WithType); } else { - snprintf(buf,MAX_BUF, "%s\t%s\t%d\n",Who,What,WhatType); + snprintf(buf,MAX_BUF, "%s\t%s\t%d\n",Who,What,WhatType); } len=strlen(buf); for(i=1; i