#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_libvar.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_utils.h"
#include "l_log.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "../game/be_ea.h"
#include "../game/be_ai_chat.h"
Include dependency graph for be_ai_chat.c:

Go to the source code of this file.
|
|
Definition at line 71 of file be_ai_chat.c. |
|
|
Definition at line 50 of file be_ai_chat.c. Referenced by BotLoadChatMessage(). |
|
|
Definition at line 59 of file be_ai_chat.c. |
|
|
Definition at line 58 of file be_ai_chat.c. |
|
|
Definition at line 61 of file be_ai_chat.c. Referenced by BotCheckValidReplyChatKeySet(). |
|
|
Definition at line 66 of file be_ai_chat.c. |
|
|
Definition at line 67 of file be_ai_chat.c. |
|
|
Definition at line 69 of file be_ai_chat.c. |
|
|
Definition at line 68 of file be_ai_chat.c. |
|
|
Definition at line 63 of file be_ai_chat.c. |
|
|
Definition at line 62 of file be_ai_chat.c. |
|
|
Definition at line 64 of file be_ai_chat.c. |
|
|
Definition at line 65 of file be_ai_chat.c. |
|
|
Referenced by BotCheckInitialChatIntegrety(), BotChooseInitialChatMessage(), BotDumpInitialChat(), and BotLoadInitialChat(). |
|
|
|
|
Referenced by BotCheckInitialChatIntegrety(), BotChooseInitialChatMessage(), BotDumpInitialChat(), BotLoadInitialChat(), and BotNumInitialChats(). |
|
|
Referenced by BotCheckValidReplyChatKeySet(), BotDumpMatchTemplates(), BotDumpReplyChat(), BotFreeMatchPieces(), BotLoadMatchPieces(), BotPrintReplyChatKeys(), and StringsMatch(). |
|
|
Referenced by BotCheckValidReplyChatKeySet(), BotDumpMatchTemplates(), BotFreeMatchPieces(), BotLoadMatchPieces(), and StringsMatch(). |
|
|
Referenced by BotDumpMatchTemplates(), BotFindMatch(), BotFreeMatchTemplates(), and BotLoadMatchTemplates(). |
|
|
Referenced by BotDumpRandomStringList(), BotLoadRandomStrings(), and RandomString(). |
|
|
Referenced by BotDumpRandomStringList(), BotLoadRandomStrings(), and RandomString(). |
|
|
Referenced by BotCheckReplyChatIntegrety(), BotDumpReplyChat(), BotFreeReplyChat(), BotLoadReplyChat(), BotPrintReplyChatKeys(), BotReplyChat(), and BotResetChatAI(). |
|
|
Referenced by BotCheckValidReplyChatKeySet(), BotDumpReplyChat(), BotFreeReplyChat(), BotLoadReplyChat(), BotPrintReplyChatKeys(), and BotReplyChat(). |
|
|
Referenced by BotCheckChatMessageIntegrety(), BotCheckInitialChatIntegrety(), BotCheckReplyChatIntegrety(), and BotFindStringInList(). |
|
|
Referenced by BotDumpSynonymList(), BotLoadSynonyms(), BotReplaceReplySynonyms(), BotReplaceSynonyms(), and BotReplaceWeightedSynonyms(). |
|
|
Referenced by BotDumpSynonymList(), BotLoadSynonyms(), BotReplaceReplySynonyms(), BotReplaceSynonyms(), and BotReplaceWeightedSynonyms(). |
|
|
Definition at line 268 of file be_ai_chat.c. References bot_consolemessage_t, freeconsolemessages, bot_consolemessage_s::next, and bot_consolemessage_s::prev. Referenced by BotQueueConsoleMessage(). 00269 {
00270 bot_consolemessage_t *message;
00271 message = freeconsolemessages;
00272 if (freeconsolemessages) freeconsolemessages = freeconsolemessages->next;
00273 if (freeconsolemessages) freeconsolemessages->prev = NULL;
00274 return message;
00275 } //end of the function AllocConsoleMessage
|
|
|
Definition at line 2895 of file be_ai_chat.c. References bot_chatstate_t, botchatstates, GetClearedMemory(), and i. 02896 {
02897 int i;
02898
02899 for (i = 1; i <= MAX_CLIENTS; i++)
02900 {
02901 if (!botchatstates[i])
02902 {
02903 botchatstates[i] = GetClearedMemory(sizeof(bot_chatstate_t));
02904 return i;
02905 } //end if
02906 } //end for
02907 return 0;
02908 } //end of the function BotAllocChatState
|
Here is the call graph for this function:

|
|
Definition at line 2771 of file be_ai_chat.c. References bot_chatstate_t, BotChatStateFromHandle(), bot_chatstate_s::chatmessage, and strlen(). 02772 {
02773 bot_chatstate_t *cs;
02774
02775 cs = BotChatStateFromHandle(chatstate);
02776 if (!cs) return 0;
02777 return strlen(cs->chatmessage);
02778 } //end of the function BotChatLength
|
Here is the call graph for this function:

|
|
Definition at line 219 of file be_ai_chat.c. References bot_chatstate_t, botchatstates, botimport, and PRT_FATAL. Referenced by BotChatLength(), BotEnterChat(), BotFreeChatFile(), BotGetChatMessage(), BotInitialChat(), BotLoadChatFile(), BotNextConsoleMessage(), BotNumConsoleMessages(), BotNumInitialChats(), BotQueueConsoleMessage(), BotRemoveConsoleMessage(), BotReplyChat(), BotSetChatGender(), and BotSetChatName(). 00220 {
00221 if (handle <= 0 || handle > MAX_CLIENTS)
00222 {
00223 botimport.Print(PRT_FATAL, "chat state handle %d out of range\n", handle);
00224 return NULL;
00225 } //end if
00226 if (!botchatstates[handle])
00227 {
00228 botimport.Print(PRT_FATAL, "invalid chat state %d\n", handle);
00229 return NULL;
00230 } //end if
00231 return botchatstates[handle];
00232 } //end of the function BotChatStateFromHandle
|
|
||||||||||||
|
Definition at line 1513 of file be_ai_chat.c. References bot_stringlist_t, BotFindStringInList(), botimport, GetClearedMemory(), i, Log_Write(), bot_stringlist_s::next, PRT_FATAL, RandomString(), s, strcpy(), bot_stringlist_s::string, and strlen(). Referenced by BotCheckInitialChatIntegrety(), and BotCheckReplyChatIntegrety(). 01514 {
01515 int i;
01516 char *msgptr;
01517 char temp[MAX_MESSAGE_SIZE];
01518 bot_stringlist_t *s;
01519
01520 msgptr = message;
01521 //
01522 while(*msgptr)
01523 {
01524 if (*msgptr == ESCAPE_CHAR)
01525 {
01526 msgptr++;
01527 switch(*msgptr)
01528 {
01529 case 'v': //variable
01530 {
01531 //step over the 'v'
01532 msgptr++;
01533 while(*msgptr && *msgptr != ESCAPE_CHAR) msgptr++;
01534 //step over the trailing escape char
01535 if (*msgptr) msgptr++;
01536 break;
01537 } //end case
01538 case 'r': //random
01539 {
01540 //step over the 'r'
01541 msgptr++;
01542 for (i = 0; (*msgptr && *msgptr != ESCAPE_CHAR); i++)
01543 {
01544 temp[i] = *msgptr++;
01545 } //end while
01546 temp[i] = '\0';
01547 //step over the trailing escape char
01548 if (*msgptr) msgptr++;
01549 //find the random keyword
01550 if (!RandomString(temp))
01551 {
01552 if (!BotFindStringInList(stringlist, temp))
01553 {
01554 Log_Write("%s = {\"%s\"} //MISSING RANDOM\r\n", temp, temp);
01555 s = GetClearedMemory(sizeof(bot_stringlist_t) + strlen(temp) + 1);
01556 s->string = (char *) s + sizeof(bot_stringlist_t);
01557 strcpy(s->string, temp);
01558 s->next = stringlist;
01559 stringlist = s;
01560 } //end if
01561 } //end if
01562 break;
01563 } //end case
01564 default:
01565 {
01566 botimport.Print(PRT_FATAL, "BotCheckChatMessageIntegrety: message \"%s\" invalid escape char\n", message);
01567 break;
01568 } //end default
01569 } //end switch
01570 } //end if
01571 else
01572 {
01573 msgptr++;
01574 } //end else
01575 } //end while
01576 return stringlist;
01577 } //end of the function BotCheckChatMessageIntegrety
|
Here is the call graph for this function:

|
|
Definition at line 1584 of file be_ai_chat.c. References bot_chat_t, bot_chatmessage_t, bot_chattype_t, bot_stringlist_t, BotCheckChatMessageIntegrety(), cm, bot_chattype_s::firstchatmessage, FreeMemory(), bot_stringlist_s::next, bot_chattype_s::next, s, t, and bot_chat_s::types. Referenced by BotLoadInitialChat(). 01585 {
01586 bot_chattype_t *t;
01587 bot_chatmessage_t *cm;
01588 bot_stringlist_t *stringlist, *s, *nexts;
01589
01590 stringlist = NULL;
01591 for (t = chat->types; t; t = t->next)
01592 {
01593 for (cm = t->firstchatmessage; cm; cm = cm->next)
01594 {
01595 stringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist);
01596 } //end for
01597 } //end for
01598 for (s = stringlist; s; s = nexts)
01599 {
01600 nexts = s->next;
01601 FreeMemory(s);
01602 } //end for
01603 } //end of the function BotCheckInitialChatIntegrety
|
Here is the call graph for this function:

|
|
Definition at line 1610 of file be_ai_chat.c. References bot_chatmessage_t, bot_replychat_t, bot_stringlist_t, BotCheckChatMessageIntegrety(), cm, bot_replychat_s::firstchatmessage, FreeMemory(), bot_stringlist_s::next, bot_replychat_s::next, and s. Referenced by BotLoadReplyChat(). 01611 {
01612 bot_replychat_t *rp;
01613 bot_chatmessage_t *cm;
01614 bot_stringlist_t *stringlist, *s, *nexts;
01615
01616 stringlist = NULL;
01617 for (rp = replychat; rp; rp = rp->next)
01618 {
01619 for (cm = rp->firstchatmessage; cm; cm = cm->next)
01620 {
01621 stringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist);
01622 } //end for
01623 } //end for
01624 for (s = stringlist; s; s = nexts)
01625 {
01626 nexts = s->next;
01627 FreeMemory(s);
01628 } //end for
01629 } //end of the function BotCheckReplyChatIntegrety
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1721 of file be_ai_chat.c. References bot_matchpiece_t, bot_matchstring_t, bot_replychatkey_t, bot_matchpiece_s::firststring, bot_replychatkey_s::flags, m, bot_replychatkey_s::match, bot_matchstring_s::next, bot_matchpiece_s::next, bot_replychatkey_s::next, qfalse, RCKFL_AND, source, source_t, SourceWarning(), bot_replychatkey_s::string, bot_matchstring_s::string, StringContains(), and bot_matchpiece_s::type. Referenced by BotLoadReplyChat(). 01722 {
01723 int allprefixed, hasvariableskey, hasstringkey;
01724 bot_matchpiece_t *m;
01725 bot_matchstring_t *ms;
01726 bot_replychatkey_t *key, *key2;
01727
01728 //
01729 allprefixed = qtrue;
01730 hasvariableskey = hasstringkey = qfalse;
01731 for (key = keys; key; key = key->next)
01732 {
01733 if (!(key->flags & (RCKFL_AND|RCKFL_NOT)))
01734 {
01735 allprefixed = qfalse;
01736 if (key->flags & RCKFL_VARIABLES)
01737 {
01738 for (m = key->match; m; m = m->next)
01739 {
01740 if (m->type == MT_VARIABLE) hasvariableskey = qtrue;
01741 } //end for
01742 } //end if
01743 else if (key->flags & RCKFL_STRING)
01744 {
01745 hasstringkey = qtrue;
01746 } //end else if
01747 } //end if
01748 else if ((key->flags & RCKFL_AND) && (key->flags & RCKFL_STRING))
01749 {
01750 for (key2 = keys; key2; key2 = key2->next)
01751 {
01752 if (key2 == key) continue;
01753 if (key2->flags & RCKFL_NOT) continue;
01754 if (key2->flags & RCKFL_VARIABLES)
01755 {
01756 for (m = key2->match; m; m = m->next)
01757 {
01758 if (m->type == MT_STRING)
01759 {
01760 for (ms = m->firststring; ms; ms = ms->next)
01761 {
01762 if (StringContains(ms->string, key->string, qfalse) != -1)
01763 {
01764 break;
01765 } //end if
01766 } //end for
01767 if (ms) break;
01768 } //end if
01769 else if (m->type == MT_VARIABLE)
01770 {
01771 break;
01772 } //end if
01773 } //end for
01774 if (!m)
01775 {
01776 SourceWarning(source, "one of the match templates does not "
01777 "leave space for the key %s with the & prefix", key->string);
01778 } //end if
01779 } //end if
01780 } //end for
01781 } //end else
01782 if ((key->flags & RCKFL_NOT) && (key->flags & RCKFL_STRING))
01783 {
01784 for (key2 = keys; key2; key2 = key2->next)
01785 {
01786 if (key2 == key) continue;
01787 if (key2->flags & RCKFL_NOT) continue;
01788 if (key2->flags & RCKFL_STRING)
01789 {
01790 if (StringContains(key2->string, key->string, qfalse) != -1)
01791 {
01792 SourceWarning(source, "the key %s with prefix ! is inside the key %s", key->string, key2->string);
01793 } //end if
01794 } //end if
01795 else if (key2->flags & RCKFL_VARIABLES)
01796 {
01797 for (m = key2->match; m; m = m->next)
01798 {
01799 if (m->type == MT_STRING)
01800 {
01801 for (ms = m->firststring; ms; ms = ms->next)
01802 {
01803 if (StringContains(ms->string, key->string, qfalse) != -1)
01804 {
01805 SourceWarning(source, "the key %s with prefix ! is inside "
01806 "the match template string %s", key->string, ms->string);
01807 } //end if
01808 } //end for
01809 } //end if
01810 } //end for
01811 } //end else if
01812 } //end for
01813 } //end if
01814 } //end for
01815 if (allprefixed) SourceWarning(source, "all keys have a & or ! prefix");
01816 if (hasvariableskey && hasstringkey)
01817 {
01818 SourceWarning(source, "variables from the match template(s) could be "
01819 "invalid when outputting one of the chat messages");
01820 } //end if
01821 } //end of the function BotCheckValidReplyChatKeySet
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2407 of file be_ai_chat.c. References AAS_Time(), bot_chat_t, bot_chatmessage_t, bot_chatstate_t, bot_chattype_t, bot_chatstate_s::chat, bot_chatmessage_s::chatmessage, bot_chattype_s::firstchatmessage, m, n, bot_chattype_s::name, bot_chatmessage_s::next, bot_chattype_s::next, Q_stricmp(), random, t, bot_chatmessage_s::time, type, and bot_chat_s::types. Referenced by BotInitialChat(). 02408 {
02409 int n, numchatmessages;
02410 float besttime;
02411 bot_chattype_t *t;
02412 bot_chatmessage_t *m, *bestchatmessage;
02413 bot_chat_t *chat;
02414
02415 chat = cs->chat;
02416 for (t = chat->types; t; t = t->next)
02417 {
02418 if (!Q_stricmp(t->name, type))
02419 {
02420 numchatmessages = 0;
02421 for (m = t->firstchatmessage; m; m = m->next)
02422 {
02423 if (m->time > AAS_Time()) continue;
02424 numchatmessages++;
02425 } //end if
02426 //if all chat messages have been used recently
02427 if (numchatmessages <= 0)
02428 {
02429 besttime = 0;
02430 bestchatmessage = NULL;
02431 for (m = t->firstchatmessage; m; m = m->next)
02432 {
02433 if (!besttime || m->time < besttime)
02434 {
02435 bestchatmessage = m;
02436 besttime = m->time;
02437 } //end if
02438 } //end for
02439 if (bestchatmessage) return bestchatmessage->chatmessage;
02440 } //end if
02441 else //choose a chat message randomly
02442 {
02443 n = random() * numchatmessages;
02444 for (m = t->firstchatmessage; m; m = m->next)
02445 {
02446 if (m->time > AAS_Time()) continue;
02447 if (--n < 0)
02448 {
02449 m->time = AAS_Time() + CHATMESSAGE_RECENTTIME;
02450 return m->chatmessage;
02451 } //end if
02452 } //end for
02453 } //end else
02454 return NULL;
02455 } //end if
02456 } //end for
02457 return NULL;
02458 } //end of the function BotChooseInitialChatMessage
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Definition at line 2379 of file be_ai_chat.c. References bot_chatstate_t, bot_match_t, BotExpandChatMessage(), botimport, bot_chatstate_s::chatmessage, i, match(), PRT_WARNING, and strcpy(). Referenced by BotInitialChat(), and BotReplyChat(). 02381 {
02382 int i;
02383 char srcmessage[MAX_MESSAGE_SIZE];
02384
02385 strcpy(srcmessage, message);
02386 for (i = 0; i < 10; i++)
02387 {
02388 if (!BotExpandChatMessage(chatstate->chatmessage, srcmessage, mcontext, match, vcontext, reply))
02389 {
02390 break;
02391 } //end if
02392 strcpy(srcmessage, chatstate->chatmessage);
02393 } //end for
02394 if (i >= 10)
02395 {
02396 botimport.Print(PRT_WARNING, "too many expansions in chat message\n");
02397 botimport.Print(PRT_WARNING, "%s\n", chatstate->chatmessage);
02398 } //end if
02399 } //end of the function BotConstructChatMessage
|
Here is the call graph for this function:

|
|
Definition at line 1988 of file be_ai_chat.c. References bot_chat_t, bot_chatmessage_t, bot_chattype_t, bot_chatmessage_s::chatmessage, bot_chattype_s::firstchatmessage, Log_Write(), m, bot_chattype_s::name, bot_chatmessage_s::next, bot_chattype_s::next, bot_chattype_s::numchatmessages, t, and bot_chat_s::types. 01989 {
01990 bot_chattype_t *t;
01991 bot_chatmessage_t *m;
01992
01993 Log_Write("{");
01994 for (t = chat->types; t; t = t->next)
01995 {
01996 Log_Write(" type \"%s\"", t->name);
01997 Log_Write(" {");
01998 Log_Write(" numchatmessages = %d", t->numchatmessages);
01999 for (m = t->firstchatmessage; m; m = m->next)
02000 {
02001 Log_Write(" \"%s\"", m->chatmessage);
02002 } //end for
02003 Log_Write(" }");
02004 } //end for
02005 Log_Write("}");
02006 } //end of the function BotDumpInitialChat
|
Here is the call graph for this function:

|
|
Definition at line 1077 of file be_ai_chat.c. References bot_matchpiece_t, bot_matchstring_t, bot_matchtemplate_t, bot_matchtemplate_s::first, bot_matchpiece_s::firststring, fp, fprintf(), Log_FilePointer(), bot_matchstring_s::next, |