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

Comparing deliantra/server/socket/request.c (file contents):
Revision 1.6 by root, Mon Apr 17 07:31:54 2006 UTC vs.
Revision 1.10 by root, Mon Jun 19 10:15:44 2006 UTC

1/* 1/*
2 * static char *rcsid_init_c = 2 * static char *rcsid_init_c =
3 * "$Id: request.c,v 1.6 2006/04/17 07:31:54 root Exp $"; 3 * "$Id: request.c,v 1.10 2006/06/19 10:15:44 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
137 else 137 else
138 snprintf (buf, MAX_BUF, "mapinfo current"); 138 snprintf (buf, MAX_BUF, "mapinfo current");
139 139
140 Write_String_To_Socket (&pl->socket, buf, strlen (buf)); 140 Write_String_To_Socket (&pl->socket, buf, strlen (buf));
141 } 141 }
142}
143
144void ExtCmd (char *buf, int len, player *pl)
145{
146 execute_global_event (EVENT_EXTCMD, pl, buf, len);
142} 147}
143 148
144void MapInfoCmd (char *buf, int len, player *pl) 149void MapInfoCmd (char *buf, int len, player *pl)
145{ 150{
146 // <mapinfo tag spatial tile-path 151 // <mapinfo tag spatial tile-path
284// } else if (!strcmp(cmd,"plugincmd")) { 289// } else if (!strcmp(cmd,"plugincmd")) {
285// ns->plugincmd = atoi(param); 290// ns->plugincmd = atoi(param);
286// safe_strcat(cmdback, param, &slen, HUGE_BUF); 291// safe_strcat(cmdback, param, &slen, HUGE_BUF);
287 } else if (!strcmp(cmd,"mapinfocmd")) { 292 } else if (!strcmp(cmd,"mapinfocmd")) {
288 ns->mapinfocmd = atoi(param); 293 ns->mapinfocmd = atoi(param);
289 safe_strcat(cmdback, param, &slen, HUGE_BUF); 294 safe_strcat(cmdback, "1", &slen, HUGE_BUF);
295 } else if (!strcmp(cmd,"extcmd")) {
296 ns->extcmd = atoi(param);
297 safe_strcat(cmdback, "1", &slen, HUGE_BUF);
290 } else if (!strcmp(cmd,"facecache")) { 298 } else if (!strcmp(cmd,"facecache")) {
291 ns->facecache = atoi(param); 299 ns->facecache = atoi(param);
292 safe_strcat(cmdback, param, &slen, HUGE_BUF); 300 safe_strcat(cmdback, param, &slen, HUGE_BUF);
293 } else if (!strcmp(cmd,"faceset")) { 301 } else if (!strcmp(cmd,"faceset")) {
294 char tmpbuf[20]; 302 char tmpbuf[20];
586 short packet; 594 short packet;
587 char command[MAX_BUF]; 595 char command[MAX_BUF];
588 SockList sl; 596 SockList sl;
589 597
590 if (len < 7) { 598 if (len < 7) {
591 LOG(llevDebug,"Corrupt ncom command - not long enough - discarding\n"); 599 LOG(llevDebug,"Corrupt ncom command <%s> not long enough - discarding\n", buf);
592 return; 600 return;
593 } 601 }
594 602
595 packet = GetShort_String(buf); 603 packet = GetShort_String(buf);
596 repeat = GetInt_String(buf+2); 604 repeat = GetInt_String(buf+2);
1603 1611
1604 for(y=pl->y-pl->contr->socket.mapy/2; y<max_y; y++,ay++) { 1612 for(y=pl->y-pl->contr->socket.mapy/2; y<max_y; y++,ay++) {
1605 ax=0; 1613 ax=0;
1606 for(x=pl->x-pl->contr->socket.mapx/2;x<max_x;x++,ax++) { 1614 for(x=pl->x-pl->contr->socket.mapx/2;x<max_x;x++,ax++) {
1607 1615
1608 mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1609 emask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1616 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1610 1617
1611 /* If this space is out of the normal viewable area, we only check 1618 /* If this space is out of the normal viewable area, we only check
1612 * the heads value ax or ay will only be greater than what 1619 * the heads value ax or ay will only be greater than what
1613 * the client wants if using the map1a command - this is because 1620 * the client wants if using the map1a command - this is because
1614 * if the map1a command is not used, max_x and max_y will be 1621 * if the map1a command is not used, max_x and max_y will be
2052 for (i=1; i< NUM_SKILLS; i++) { 2059 for (i=1; i< NUM_SKILLS; i++) {
2053 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO, 2060 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO,
2054 skill_names[i]); 2061 skill_names[i]);
2055 } 2062 }
2056 sl.len = strlen((char*)sl.buf); 2063 sl.len = strlen((char*)sl.buf);
2057 if (sl.len > MAXSOCKBUF) { 2064 if (sl.len >= MAXSOCKBUF) {
2058 LOG(llevError,"Buffer overflow in send_skill_info!\n"); 2065 LOG(llevError,"Buffer overflow in send_skill_info!\n");
2059 fatal(0); 2066 fatal(0);
2060 } 2067 }
2061 Send_With_Handling(ns, &sl); 2068 Send_With_Handling(ns, &sl);
2062 free(sl.buf); 2069 free(sl.buf);
2073 sl.buf = malloc(MAXSOCKBUF); 2080 sl.buf = malloc(MAXSOCKBUF);
2074 strcpy((char*)sl.buf,"replyinfo spell_paths\n"); 2081 strcpy((char*)sl.buf,"replyinfo spell_paths\n");
2075 for(i=0; i<NRSPELLPATHS; i++) 2082 for(i=0; i<NRSPELLPATHS; i++)
2076 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]); 2083 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]);
2077 sl.len = strlen((char*)sl.buf); 2084 sl.len = strlen((char*)sl.buf);
2078 if (sl.len > MAXSOCKBUF) { 2085 if (sl.len >= MAXSOCKBUF) {
2079 LOG(llevError,"Buffer overflow in send_spell_paths!\n"); 2086 LOG(llevError,"Buffer overflow in send_spell_paths!\n");
2080 fatal(0); 2087 fatal(0);
2081 } 2088 }
2082 Send_With_Handling(ns, &sl); 2089 Send_With_Handling(ns, &sl);
2083 free(sl.buf); 2090 free(sl.buf);
2217 * to show add_spell is 26 bytes + 2 strings. However, the overun 2224 * to show add_spell is 26 bytes + 2 strings. However, the overun
2218 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem 2225 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem
2219 * like it will fix this 2226 * like it will fix this
2220 */ 2227 */
2221 if (spell->type != SPELL) continue; 2228 if (spell->type != SPELL) continue;
2222 if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) + 2229 if (sl.len >= (MAXSOCKBUF - (26 + strlen(spell->name) +
2223 (spell->msg?strlen(spell->msg):0)))) { 2230 (spell->msg?strlen(spell->msg):0)))) {
2224 Send_With_Handling(&pl->socket, &sl); 2231 Send_With_Handling(&pl->socket, &sl);
2225 strcpy((char*)sl.buf,"addspell "); 2232 strcpy((char*)sl.buf,"addspell ");
2226 sl.len=strlen((char*)sl.buf); 2233 sl.len=strlen((char*)sl.buf);
2227 } 2234 }
2231 else if (spell->type != SPELL) { 2238 else if (spell->type != SPELL) {
2232 LOG(llevError, "Asked to send a non-spell object as a spell"); 2239 LOG(llevError, "Asked to send a non-spell object as a spell");
2233 return; 2240 return;
2234 } 2241 }
2235 else append_spell(pl, &sl, spell); 2242 else append_spell(pl, &sl, spell);
2236 if (sl.len > MAXSOCKBUF) { 2243 if (sl.len >= MAXSOCKBUF) {
2237 LOG(llevError,"Buffer overflow in esrv_add_spells!\n"); 2244 LOG(llevError,"Buffer overflow in esrv_add_spells!\n");
2238 fatal(0); 2245 fatal(0);
2239 } 2246 }
2240 /* finally, we can send the packet */ 2247 /* finally, we can send the packet */
2241 Send_With_Handling(&pl->socket, &sl); 2248 Send_With_Handling(&pl->socket, &sl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines