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.5 by root, Mon Apr 17 06:11:41 2006 UTC vs.
Revision 1.9 by root, Sun Jun 11 15:02:17 2006 UTC

1/* 1/*
2 * static char *rcsid_init_c = 2 * static char *rcsid_init_c =
3 * "$Id: request.c,v 1.5 2006/04/17 06:11:41 root Exp $"; 3 * "$Id: request.c,v 1.9 2006/06/11 15:02:17 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);
787{ 795{
788 if( pl->socket.newmapcmd == 1) { 796 if( pl->socket.newmapcmd == 1) {
789 memset(&pl->socket.lastmap, 0, sizeof(pl->socket.lastmap)); 797 memset(&pl->socket.lastmap, 0, sizeof(pl->socket.lastmap));
790 Write_String_To_Socket( &pl->socket, "newmap", 6); 798 Write_String_To_Socket( &pl->socket, "newmap", 6);
791 } 799 }
800 pl->socket.current_map = 0;
792} 801}
793 802
794 803
795 804
796/** 805/**
2051 for (i=1; i< NUM_SKILLS; i++) { 2060 for (i=1; i< NUM_SKILLS; i++) {
2052 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO, 2061 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO,
2053 skill_names[i]); 2062 skill_names[i]);
2054 } 2063 }
2055 sl.len = strlen((char*)sl.buf); 2064 sl.len = strlen((char*)sl.buf);
2056 if (sl.len > MAXSOCKBUF) { 2065 if (sl.len >= MAXSOCKBUF) {
2057 LOG(llevError,"Buffer overflow in send_skill_info!\n"); 2066 LOG(llevError,"Buffer overflow in send_skill_info!\n");
2058 fatal(0); 2067 fatal(0);
2059 } 2068 }
2060 Send_With_Handling(ns, &sl); 2069 Send_With_Handling(ns, &sl);
2061 free(sl.buf); 2070 free(sl.buf);
2072 sl.buf = malloc(MAXSOCKBUF); 2081 sl.buf = malloc(MAXSOCKBUF);
2073 strcpy((char*)sl.buf,"replyinfo spell_paths\n"); 2082 strcpy((char*)sl.buf,"replyinfo spell_paths\n");
2074 for(i=0; i<NRSPELLPATHS; i++) 2083 for(i=0; i<NRSPELLPATHS; i++)
2075 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]); 2084 sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]);
2076 sl.len = strlen((char*)sl.buf); 2085 sl.len = strlen((char*)sl.buf);
2077 if (sl.len > MAXSOCKBUF) { 2086 if (sl.len >= MAXSOCKBUF) {
2078 LOG(llevError,"Buffer overflow in send_spell_paths!\n"); 2087 LOG(llevError,"Buffer overflow in send_spell_paths!\n");
2079 fatal(0); 2088 fatal(0);
2080 } 2089 }
2081 Send_With_Handling(ns, &sl); 2090 Send_With_Handling(ns, &sl);
2082 free(sl.buf); 2091 free(sl.buf);
2216 * to show add_spell is 26 bytes + 2 strings. However, the overun 2225 * to show add_spell is 26 bytes + 2 strings. However, the overun
2217 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem 2226 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem
2218 * like it will fix this 2227 * like it will fix this
2219 */ 2228 */
2220 if (spell->type != SPELL) continue; 2229 if (spell->type != SPELL) continue;
2221 if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) + 2230 if (sl.len >= (MAXSOCKBUF - (26 + strlen(spell->name) +
2222 (spell->msg?strlen(spell->msg):0)))) { 2231 (spell->msg?strlen(spell->msg):0)))) {
2223 Send_With_Handling(&pl->socket, &sl); 2232 Send_With_Handling(&pl->socket, &sl);
2224 strcpy((char*)sl.buf,"addspell "); 2233 strcpy((char*)sl.buf,"addspell ");
2225 sl.len=strlen((char*)sl.buf); 2234 sl.len=strlen((char*)sl.buf);
2226 } 2235 }
2230 else if (spell->type != SPELL) { 2239 else if (spell->type != SPELL) {
2231 LOG(llevError, "Asked to send a non-spell object as a spell"); 2240 LOG(llevError, "Asked to send a non-spell object as a spell");
2232 return; 2241 return;
2233 } 2242 }
2234 else append_spell(pl, &sl, spell); 2243 else append_spell(pl, &sl, spell);
2235 if (sl.len > MAXSOCKBUF) { 2244 if (sl.len >= MAXSOCKBUF) {
2236 LOG(llevError,"Buffer overflow in esrv_add_spells!\n"); 2245 LOG(llevError,"Buffer overflow in esrv_add_spells!\n");
2237 fatal(0); 2246 fatal(0);
2238 } 2247 }
2239 /* finally, we can send the packet */ 2248 /* finally, we can send the packet */
2240 Send_With_Handling(&pl->socket, &sl); 2249 Send_With_Handling(&pl->socket, &sl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines