Plugins: chatsounds.dat will now look for any definitions
file named chatsounds_*.txt.
This commit is contained in:
parent
81116646e4
commit
034575ac87
2 changed files with 35 additions and 27 deletions
85
src/plugins/chatsounds.qc
Executable file → Normal file
85
src/plugins/chatsounds.qc
Executable file → Normal file
|
@ -55,6 +55,49 @@ ChatLookUp(string cmd)
|
|||
return (__NULL__);
|
||||
}
|
||||
|
||||
void
|
||||
ChatLoadFile(string filename)
|
||||
{
|
||||
string temp;
|
||||
int c = 0;
|
||||
int i = g_sounds;
|
||||
filestream chatfile;
|
||||
chatfile = fopen(filename, FILE_READ);
|
||||
|
||||
if (chatfile < 0) {
|
||||
print(sprintf("[CHATSOUNDS] %s not found.\n", filename));
|
||||
return;
|
||||
}
|
||||
|
||||
/* count lines */
|
||||
while ((temp = fgets(chatfile))) {
|
||||
c = tokenize_console(temp);
|
||||
if (c != 2) {
|
||||
continue;
|
||||
}
|
||||
g_sounds++;
|
||||
}
|
||||
fseek(chatfile, 0);
|
||||
|
||||
g_table = (chatsentence_t *)memrealloc(g_table, sizeof(chatsentence_t), i, g_sounds);
|
||||
|
||||
while ((temp = fgets(chatfile))) {
|
||||
c = tokenize_console(temp);
|
||||
if (c != 2) {
|
||||
continue;
|
||||
}
|
||||
g_table[i].sentence = strtolower(argv(0));
|
||||
g_table[i].sample = strtolower(argv(1));
|
||||
c = tokenizebyseparator(g_table[i].sample, ";");
|
||||
for (int x = 0; x < c; x++) {
|
||||
precache_sound(argv(x));
|
||||
print(sprintf("[CHATSOUNDS] Caching: %s\n", argv(x)));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
fclose(chatfile);
|
||||
}
|
||||
|
||||
/* plugin hook */
|
||||
string
|
||||
FMX_ParseClientCommand(string cmd)
|
||||
|
@ -71,51 +114,15 @@ FMX_ParseClientCommand(string cmd)
|
|||
void
|
||||
FMX_Init(void)
|
||||
{
|
||||
string temp;
|
||||
int i = 0;
|
||||
int c = 0;
|
||||
filestream chatfile;
|
||||
searchhandle list;
|
||||
|
||||
list = search_begin("plugins/chatsounds/*.txt", FALSE, TRUE);
|
||||
list = search_begin("chatsounds_*.txt", FALSE, TRUE);
|
||||
for (i = 0; i < search_getsize(list); i++) {
|
||||
print(sprintf("Found %s\n", search_getfilename(list, i)));
|
||||
print(sprintf("[CHATSOUNDS] Found %s\n", search_getfilename(list, i)));
|
||||
ChatLoadFile(search_getfilename(list, i));
|
||||
}
|
||||
search_end(list);
|
||||
|
||||
chatfile = fopen("chatsounds.txt", FILE_READ);
|
||||
|
||||
if (chatfile < 0) {
|
||||
print("Chat Sound Plugin: chatsounds.txt not found.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* count lines */
|
||||
while ((temp = fgets(chatfile))) {
|
||||
c = tokenize_console(temp);
|
||||
if (c != 2) {
|
||||
continue;
|
||||
}
|
||||
g_sounds++;
|
||||
}
|
||||
fseek(chatfile, 0);
|
||||
|
||||
g_table = memalloc(sizeof(chatsentence_t) * g_sounds);
|
||||
while ((temp = fgets(chatfile))) {
|
||||
c = tokenize_console(temp);
|
||||
if (c != 2) {
|
||||
continue;
|
||||
}
|
||||
g_table[i].sentence = strtolower(argv(0));
|
||||
g_table[i].sample = strtolower(argv(1));
|
||||
c = tokenizebyseparator(g_table[i].sample, ";");
|
||||
for (int x = 0; x < c; x++) {
|
||||
precache_sound(argv(x));
|
||||
print(sprintf("Caching: %s\n", argv(x)));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
fclose(chatfile);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
1
src/plugins/chatsounds.src
Executable file → Normal file
1
src/plugins/chatsounds.src
Executable file → Normal file
|
@ -4,5 +4,6 @@
|
|||
|
||||
#includelist
|
||||
../shared/fteextensions.qc
|
||||
../shared/memory.h
|
||||
chatsounds.qc
|
||||
#endlist
|
||||
|
|
Loading…
Reference in a new issue