version 1.49 | | version 1.50 |
---|
| | |
/* | | /* |
* static char *rcsid_init_c = | | * static char *rcsid_init_c = |
* "$Id: request.c,v 1.49 2003/06/19 10:59:33 tchize Exp $"; | | * "$Id: request.c,v 1.50 2003/07/08 12:45:28 tchize Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
strncpy (command,&(buf[info]),nextinfo-info); | | strncpy (command,&(buf[info]),nextinfo-info); |
command[nextinfo-info]='\0'; | | command[nextinfo-info]='\0'; |
/* 2. Interpret info*/ | | /* 2. Interpret info*/ |
if (!strcmp("smoothing",command)){ | | if (!strcmp("smooth",command)){ |
/* Toggle smoothing*/ | | /* Toggle smoothing*/ |
ns->EMI_smooth=!ns->EMI_smooth; | | ns->EMI_smooth=!ns->EMI_smooth; |
}else{ | | }else{ |
| | |
char* defaultsmooth="default_smoothed.111"; | | char* defaultsmooth="default_smoothed.111"; |
char smoothname[MAX_BUF]; | | char smoothname[MAX_BUF]; |
char reply[MAX_BUF]; | | char reply[MAX_BUF]; |
| | SockList sl; |
int i; | | int i; |
int smoothed[8]; | | |
archetype* at; | | archetype* at; |
uint16 smoothfaces[8]; /*unsigned short int!*/ | | uint16 smoothface; |
int facenbr; | | int facenbr; |
facenbr=atoi (buf); | | facenbr=atoi (buf); |
if ((!FindSmooth (facenbr, smoothfaces)) && | | if ((!FindSmooth (facenbr, &smoothface)) && |
(!FindSmooth (FindFace(defaultsmooth,0), smoothfaces)) | | (!FindSmooth (FindFace(defaultsmooth,0), &smoothface)) |
) | | ) |
| | |
LOG(llevError,"could not findsmooth for %d. Neither default (%s)\n",facenbr,defaultsmooth); | | LOG(llevError,"could not findsmooth for %d. Neither default (%s)\n",facenbr,defaultsmooth); |
#if 0 | | if (ns->faces_sent[smoothface] == 0) |
name = FindFaceName(facenbr, NULL); | | esrv_send_face(ns, smoothface, 0); |
if (name==NULL){ | | sl.buf=reply; |
LOG(llevError,"could not findsmooth for %d(%s). Back to default\n",facenbr); | | strcpy((char*)sl.buf,"smooth "); |
| | sl.len=strlen((char*)sl.buf); |
name=defaultsmooth; | | SockList_AddShort(&sl, facenbr); |
} | | SockList_AddShort(&sl, smoothface); |
strcpy (smoothname,name); | | Send_With_Handling(ns, &sl); |
strcat (smoothname,"_smoothed"); | | |
/* A face name may have a dot in it's name. It is a bad | | |
* idea to create an archetype with a dot in it's name. | | |
* To do handle this, let's replace all '.' with '_' | | |
*/ | | |
for (i=0;i<strlen(smoothname);i++) | | |
if (smoothname[i]=='.') | | |
smoothname[i]='_'; | | |
at=find_archetype(smoothname); | | |
if (at==NULL){ | | |
/* no correct smooth. Boggus client or boggus archetype definition | | |
* fall back to a default smooth for security reasons. | | |
* If we fail here, we have a boggus archetypes list! | | |
*/ | | |
LOG(llevError,"tried to smooth %s.\n",name); | | |
LOG(llevError,"previous: %s.\n",FindFaceName(facenbr-1, NULL)); | | |
LOG(llevError,"next: %s.\n",FindFaceName(facenbr+1, NULL)); | | |
at=find_archetype("default_smoothed"); | | |
} | | |
if (at==NULL){ | | |
LOG(llevError,"BOGGUS archetype file.\n"); | | |
LOG(llevError,"Mandatory archetype named default_smoothed not found.\n"); | | |
LOG(llevError,"Clients with smoothing will have LOTS of problems\n"); | | |
LOG(llevError,"Sending first face as default smooth sequence\n"); | | |
for (i=0;i<8;i++) | | |
smoothfaces[i]=0; | | |
if (ns->faces_sent[0] == 0) | | |
esrv_send_face(ns, 0, 0); | | |
} | | |
else{ | | |
for (i=0;i<8;i++){ | | |
smoothfaces[i]=GET_ANIMATION((&(at->clone)),i); | | |
if (ns->faces_sent[smoothfaces[i]] == 0) | | |
esrv_send_face(ns, smoothfaces[i], 0); | | |
} | | |
} | | |
#endif | | |
for (i=0;i<8;i++){ | | |
if (ns->faces_sent[smoothfaces[i]] == 0) | | |
esrv_send_face(ns, smoothfaces[i], 0); | | |
} | | |
sprintf (reply,"smooth %d %d %d %d %d %d %d %d %d",facenbr, | | |
smoothfaces[0],smoothfaces[1],smoothfaces[2],smoothfaces[3], | | |
smoothfaces[4],smoothfaces[5],smoothfaces[6],smoothfaces[7]); | | |
Write_String_To_Socket(ns, reply,strlen(reply)); | | |
| | |
} | | } |
/* This handles the general commands from the client (ie, north, fire, cast, | | /* This handles the general commands from the client (ie, north, fire, cast, |
* etc.) | | * etc.) |
| | |
* be null, so we only do this block if we are working on | | * be null, so we only do this block if we are working on |
* a tail piece. | | * a tail piece. |
*/ | | */ |
#if 0 | | |
///// Old code from update_Space, don't think tail interacts here | | |
/* tail_x and tail_y will only be set in the head object. If | | |
* this is the head object and these are set, we proceed | | |
* with logic to only send bottom right. Similarly, if | | |
* this is one of the more parts but the head has those values | | |
* set, we want to do the processing. There can be cases where | | |
* the head is not visible but one of its parts is, so we just | | |
* can always expect that ob->arch->tail_x will be true for all | | |
* object we may want to display. | | |
*/ | | |
if ((ob->arch->tail_x || ob->arch->tail_y) || | | |
(ob->head && (ob->head->arch->tail_x || ob->head->arch->tail_y))) { | | |
| | |
if (ob->head) head = ob->head; | | |
else head = ob; | | |
| | |
/* Basically figure out where the offset is from where we are right | | |
* now. the ob->arch->clone.{x,y} values hold the offset that this current | | |
* piece is from the head, and the tail is where the tail is from the | | |
* head. Note that bx and by will equal sx and sy if we are already working | | |
* on the bottom right corner. If ob is the head, the clone values | | |
* will be zero, so the right thing will still happen. | | |
*/ | | |
bx = sx + head->arch->tail_x - ob->arch->clone.x; | | |
by = sy + head->arch->tail_y - ob->arch->clone.y; | | |
| | |
/* I don't think this can ever happen, but better to check for it just | | |
* in case. | | |
*/ | | |
if (bx < sx || by < sy) { | | |
LOG(llevError,"update_space: bx (%d) or by (%d) is less than sx (%d) or sy (%d)\n", | | |
bx, by, sx, sy); | | |
} | | |
/* single part object, multipart object with non merged faces, | | |
* of multipart object already at lower right. | | |
*/ | | |
else if (bx == sx && by == sy) { | | |
face_num = ob->face->number; | | |
| | |
/* if this face matches one stored away, clear that one away. | | |
* this code relies on the fact that the map1 commands | | |
* goes from 2 down to 0. | | |
*/ | | |
for (i=0; i<MAP_LAYERS; i++) | | |
if (heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] && | | |
heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i]->face->number == face_num) | | |
heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] = NULL; | | |
} | | |
else { | | |
/* First, try to put the new head on the same layer. If that is used up, | | |
* then find another layer. | | |
*/ | | |
if (heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + layer] == NULL || | | |
heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + layer] == head) { | | |
heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + layer] = head; | | |
} else for (i=0; i<MAX_LAYERS; i++) { | | |
if (heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] == NULL || | | |
heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] == head) { | | |
heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] = head; | | |
} | | |
} | | |
face_num = 0; /* Don't send this object - we'll send the head later */ | | |
} | | |
} else { | | |
#else | | |
{ | | { |
#endif | | |
/* In this case, we are already at the lower right or single part object, | | /* In this case, we are already at the lower right or single part object, |
* so nothing special | | * so nothing special |
*/ | | */ |
| | |
SockList sl; | | SockList sl; |
SockList esl; /*For extended Map info*/ | | SockList esl; /*For extended Map info*/ |
uint16 mask,emask,eentrysize; | | uint16 mask,emask,eentrysize; |
| | uint16 ewhatstart,ewhatflag; |
uint8 extendedinfos; | | uint8 extendedinfos; |
mapstruct *m; | | mapstruct *m; |
| | |
| | |
extendedinfos=EMI_NOREDRAW; | | extendedinfos=EMI_NOREDRAW; |
if (pl->contr->socket.EMI_smooth) | | if (pl->contr->socket.EMI_smooth) |
extendedinfos|=EMI_SMOOTH; | | extendedinfos|=EMI_SMOOTH; |
| | ewhatstart=esl.len; |
| | ewhatflag=extendedinfos; /*The EMI_NOREDRAW bit |
| | could need to be taken away*/ |
SockList_AddChar(&esl, extendedinfos); | | SockList_AddChar(&esl, extendedinfos); |
eentrysize=getExtendedMapInfoSize(&(pl->contr->socket)); | | eentrysize=getExtendedMapInfoSize(&(pl->contr->socket)); |
SockList_AddChar(&esl, eentrysize); | | SockList_AddChar(&esl, eentrysize); |
| | |
if (ax >= pl->contr->socket.mapx || ay >= pl->contr->socket.mapy) { | | if (ax >= pl->contr->socket.mapx || ay >= pl->contr->socket.mapy) { |
oldlen = sl.len; | | oldlen = sl.len; |
if (pl->contr->socket.ext_mapinfos){ | | if (pl->contr->socket.ext_mapinfos){ |
SockList_AddShort(&sl, emask); | | SockList_AddShort(&esl, emask); |
} | | } |
| | |
SockList_AddShort(&sl, mask); | | SockList_AddShort(&sl, mask); |
| | |
} /* for y loop */ | | } /* for y loop */ |
| | |
/* Verify that we in fact do need to send this */ | | /* Verify that we in fact do need to send this */ |
if (pl->contr->socket.ext_mapinfos) | | if (pl->contr->socket.ext_mapinfos){ |
| | if (!(sl.len>startlen || pl->contr->socket.sent_scroll)){ |
| | /* No map data will follow, so don't say the client |
| | * it doesn't need draw! |
| | */ |
| | ewhatflag&=(~EMI_NOREDRAW); |
| | esl.buf[ewhatstart+1] = ewhatflag & 0xff; |
| | } |
if (esl.len>estartlen) { | | if (esl.len>estartlen) { |
Send_With_Handling(&pl->contr->socket, &esl); | | Send_With_Handling(&pl->contr->socket, &esl); |
free(esl.buf); | | free(esl.buf); |
} | | } |
| | } |
if (sl.len>startlen || pl->contr->socket.sent_scroll) { | | if (sl.len>startlen || pl->contr->socket.sent_scroll) { |
Send_With_Handling(&pl->contr->socket, &sl); | | Send_With_Handling(&pl->contr->socket, &sl); |
pl->contr->socket.sent_scroll = 0; | | pl->contr->socket.sent_scroll = 0; |