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.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 | |
|
|
144 | void ExtCmd (char *buf, int len, player *pl) |
|
|
145 | { |
|
|
146 | execute_global_event (EVENT_EXTCMD, pl, buf, len); |
142 | } |
147 | } |
143 | |
148 | |
144 | void MapInfoCmd (char *buf, int len, player *pl) |
149 | void 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); |
… | |
… | |
2052 | for (i=1; i< NUM_SKILLS; i++) { |
2060 | for (i=1; i< NUM_SKILLS; i++) { |
2053 | 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, |
2054 | skill_names[i]); |
2062 | skill_names[i]); |
2055 | } |
2063 | } |
2056 | sl.len = strlen((char*)sl.buf); |
2064 | sl.len = strlen((char*)sl.buf); |
2057 | if (sl.len > MAXSOCKBUF) { |
2065 | if (sl.len >= MAXSOCKBUF) { |
2058 | LOG(llevError,"Buffer overflow in send_skill_info!\n"); |
2066 | LOG(llevError,"Buffer overflow in send_skill_info!\n"); |
2059 | fatal(0); |
2067 | fatal(0); |
2060 | } |
2068 | } |
2061 | Send_With_Handling(ns, &sl); |
2069 | Send_With_Handling(ns, &sl); |
2062 | free(sl.buf); |
2070 | free(sl.buf); |
… | |
… | |
2073 | sl.buf = malloc(MAXSOCKBUF); |
2081 | sl.buf = malloc(MAXSOCKBUF); |
2074 | strcpy((char*)sl.buf,"replyinfo spell_paths\n"); |
2082 | strcpy((char*)sl.buf,"replyinfo spell_paths\n"); |
2075 | for(i=0; i<NRSPELLPATHS; i++) |
2083 | for(i=0; i<NRSPELLPATHS; i++) |
2076 | 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]); |
2077 | sl.len = strlen((char*)sl.buf); |
2085 | sl.len = strlen((char*)sl.buf); |
2078 | if (sl.len > MAXSOCKBUF) { |
2086 | if (sl.len >= MAXSOCKBUF) { |
2079 | LOG(llevError,"Buffer overflow in send_spell_paths!\n"); |
2087 | LOG(llevError,"Buffer overflow in send_spell_paths!\n"); |
2080 | fatal(0); |
2088 | fatal(0); |
2081 | } |
2089 | } |
2082 | Send_With_Handling(ns, &sl); |
2090 | Send_With_Handling(ns, &sl); |
2083 | free(sl.buf); |
2091 | free(sl.buf); |
… | |
… | |
2217 | * 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 |
2218 | * 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 |
2219 | * like it will fix this |
2227 | * like it will fix this |
2220 | */ |
2228 | */ |
2221 | if (spell->type != SPELL) continue; |
2229 | if (spell->type != SPELL) continue; |
2222 | if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) + |
2230 | if (sl.len >= (MAXSOCKBUF - (26 + strlen(spell->name) + |
2223 | (spell->msg?strlen(spell->msg):0)))) { |
2231 | (spell->msg?strlen(spell->msg):0)))) { |
2224 | Send_With_Handling(&pl->socket, &sl); |
2232 | Send_With_Handling(&pl->socket, &sl); |
2225 | strcpy((char*)sl.buf,"addspell "); |
2233 | strcpy((char*)sl.buf,"addspell "); |
2226 | sl.len=strlen((char*)sl.buf); |
2234 | sl.len=strlen((char*)sl.buf); |
2227 | } |
2235 | } |
… | |
… | |
2231 | else if (spell->type != SPELL) { |
2239 | else if (spell->type != SPELL) { |
2232 | 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"); |
2233 | return; |
2241 | return; |
2234 | } |
2242 | } |
2235 | else append_spell(pl, &sl, spell); |
2243 | else append_spell(pl, &sl, spell); |
2236 | if (sl.len > MAXSOCKBUF) { |
2244 | if (sl.len >= MAXSOCKBUF) { |
2237 | LOG(llevError,"Buffer overflow in esrv_add_spells!\n"); |
2245 | LOG(llevError,"Buffer overflow in esrv_add_spells!\n"); |
2238 | fatal(0); |
2246 | fatal(0); |
2239 | } |
2247 | } |
2240 | /* finally, we can send the packet */ |
2248 | /* finally, we can send the packet */ |
2241 | Send_With_Handling(&pl->socket, &sl); |
2249 | Send_With_Handling(&pl->socket, &sl); |