Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

be_ai_chat.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  bot_consolemessage_s
struct  bot_match_s
struct  bot_matchvariable_s

Defines

#define CHAT_ALL   0
#define CHAT_GENDERFEMALE   1
#define CHAT_GENDERLESS   0
#define CHAT_GENDERMALE   2
#define CHAT_TEAM   1
#define CHAT_TELL   2
#define MAX_CHATTYPE_NAME   32
#define MAX_MATCHVARIABLES   8
#define MAX_MESSAGE_SIZE   256

Typedefs

typedef bot_consolemessage_s bot_consolemessage_t
typedef bot_match_s bot_match_t
typedef bot_matchvariable_s bot_matchvariable_t

Functions

int BotAllocChatState (void)
int BotChatLength (int chatstate)
void BotEnterChat (int chatstate, int clientto, int sendto)
int BotFindMatch (char *str, bot_match_t *match, unsigned long int context)
void BotFreeChatState (int handle)
void BotGetChatMessage (int chatstate, char *buf, int size)
void BotInitialChat (int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7)
int BotLoadChatFile (int chatstate, char *chatfile, char *chatname)
void BotMatchVariable (bot_match_t *match, int variable, char *buf, int size)
int BotNextConsoleMessage (int chatstate, bot_consolemessage_t *cm)
int BotNumConsoleMessages (int chatstate)
int BotNumInitialChats (int chatstate, char *type)
void BotQueueConsoleMessage (int chatstate, int type, char *message)
void BotRemoveConsoleMessage (int chatstate, int handle)
void BotReplaceSynonyms (char *string, unsigned long int context)
int BotReplyChat (int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7)
void BotSetChatGender (int chatstate, int gender)
void BotSetChatName (int chatstate, char *name, int client)
int BotSetupChatAI (void)
void BotShutdownChatAI (void)
int StringContains (char *str1, char *str2, int casesensitive)
void UnifyWhiteSpaces (char *string)


Define Documentation

#define CHAT_ALL   0
 

Definition at line 40 of file be_ai_chat.h.

Referenced by BotAIShutdownClient(), and BotChatTest().

#define CHAT_GENDERFEMALE   1
 

Definition at line 37 of file be_ai_chat.h.

Referenced by BotAISetupClient(), BotDeathmatchAI(), and BotSetChatGender().

#define CHAT_GENDERLESS   0
 

Definition at line 36 of file be_ai_chat.h.

Referenced by BotAISetupClient(), and BotDeathmatchAI().

#define CHAT_GENDERMALE   2
 

Definition at line 38 of file be_ai_chat.h.

Referenced by BotAISetupClient(), BotDeathmatchAI(), and BotSetChatGender().

#define CHAT_TEAM   1
 

Definition at line 41 of file be_ai_chat.h.

Referenced by BotEnterChat(), BotGetLongTermGoal(), BotMatch_Camp(), BotMatch_HelpAccompany(), BotMatch_LeadTheWay(), BotMatch_WhichTeam(), BotTeamAI(), and BotVoiceChat_WhoIsLeader().

#define CHAT_TELL   2
 

Definition at line 42 of file be_ai_chat.h.

Referenced by BotEnterChat(), BotGetLongTermGoal(), BotLongTermGoal(), BotMatch_Camp(), BotMatch_CheckPoint(), BotMatch_Dismiss(), BotMatch_HelpAccompany(), BotMatch_JoinSubteam(), BotMatch_Kill(), BotMatch_LeaveSubteam(), BotMatch_TaskPreference(), BotMatch_WhatAreYouDoing(), BotMatch_WhereAreYou(), BotSayTeamOrderAlways(), BotVoiceChat_Camp(), BotVoiceChat_FollowMe(), BotVoiceChat_Patrol(), BotVoiceChat_WantOnDefense(), and BotVoiceChat_WantOnOffense().

#define MAX_CHATTYPE_NAME   32
 

Definition at line 33 of file be_ai_chat.h.

Referenced by BotLoadInitialChat().

#define MAX_MATCHVARIABLES   8
 

Definition at line 34 of file be_ai_chat.h.

Referenced by BotLoadMatchPieces().

#define MAX_MESSAGE_SIZE   256
 

Definition at line 32 of file be_ai_chat.h.

Referenced by BotAddressedToBot(), BotFindMatch(), BotGetPatrolWaypoints(), BotGetTime(), BotMatch_CheckPoint(), BotMatch_FormationSpace(), and BotQueueConsoleMessage().


Typedef Documentation

typedef struct bot_consolemessage_s bot_consolemessage_t
 

Referenced by AllocConsoleMessage(), BotCheckConsoleMessages(), BotFreeChatState(), BotNextConsoleMessage(), BotQueueConsoleMessage(), BotRemoveConsoleMessage(), FreeConsoleMessage(), and InitConsoleMessageHeap().

typedef struct bot_match_s bot_match_t
 

Referenced by BotAddressedToBot(), BotCheckConsoleMessages(), BotConstructChatMessage(), BotExpandChatMessage(), BotFindMatch(), BotGetPatrolWaypoints(), BotGetTime(), BotInitialChat(), BotMatch_AttackEnemyBase(), BotMatch_Camp(), BotMatch_CheckPoint(), BotMatch_CTF(), BotMatch_DefendKeyArea(), BotMatch_Dismiss(), BotMatch_EnterGame(), BotMatch_FormationSpace(), BotMatch_GetFlag(), BotMatch_GetItem(), BotMatch_HelpAccompany(), BotMatch_JoinSubteam(), BotMatch_Kill(), BotMatch_LeadTheWay(), BotMatch_LeaveSubteam(), BotMatch_NewLeader(), BotMatch_Patrol(), BotMatch_ReturnFlag(), BotMatch_RushBase(), BotMatch_StartTeamLeaderShip(), BotMatch_StopTeamLeaderShip(), BotMatch_Suicide(), BotMatch_TaskPreference(), BotMatch_WhatAreYouDoing(), BotMatch_WhatIsMyCommand(), BotMatch_WhereAreYou(), BotMatch_WhichTeam(), BotMatch_WhoIsTeamLeader(), BotMatchMessage(), BotMatchVariable(), BotReplyChat(), and StringsMatch().

typedef struct bot_matchvariable_s bot_matchvariable_t
 


Function Documentation

int BotAllocChatState void   ) 
 

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:

int BotChatLength int  chatstate  ) 
 

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:

void BotEnterChat int  chatstate,
int  clientto,
int  sendto
 

Definition at line 2785 of file be_ai_chat.c.

References bot_chatstate_t, BotChatStateFromHandle(), botimport, BotRemoveTildes(), CHAT_TEAM, CHAT_TELL, bot_chatstate_s::chatmessage, bot_chatstate_s::client, EA_Command(), LibVarGetValue(), PRT_MESSAGE, strcpy(), strlen(), and va().

02786 {
02787     bot_chatstate_t *cs;
02788 
02789     cs = BotChatStateFromHandle(chatstate);
02790     if (!cs) return;
02791 
02792     if (strlen(cs->chatmessage))
02793     {
02794         BotRemoveTildes(cs->chatmessage);
02795         if (LibVarGetValue("bot_testichat")) {
02796             botimport.Print(PRT_MESSAGE, "%s\n", cs->chatmessage);
02797         }
02798         else {
02799             switch(sendto) {
02800                 case CHAT_TEAM:
02801                     EA_Command(cs->client, va("say_team %s", cs->chatmessage));
02802                     break;
02803                 case CHAT_TELL:
02804                     EA_Command(cs->client, va("tell %d %s", clientto, cs->chatmessage));
02805                     break;
02806                 default: //CHAT_ALL
02807                     EA_Command(cs->client, va("say %s", cs->chatmessage));
02808                     break;
02809             }
02810         }
02811         //clear the chat message from the state
02812         strcpy(cs->chatmessage, "");
02813     } //end if
02814 } //end of the function BotEnterChat

Here is the call graph for this function:

int BotFindMatch char *  str,
bot_match_t match,
unsigned long int  context
 

Definition at line 1434 of file be_ai_chat.c.

References bot_match_t, bot_matchtemplate_t, bot_matchtemplate_s::context, bot_matchtemplate_s::first, i, match(), MAX_MESSAGE_SIZE, bot_matchtemplate_s::next, bot_matchvariable_s::offset, bot_match_s::string, StringsMatch(), strlen(), strncpy(), bot_matchtemplate_s::subtype, bot_match_s::subtype, bot_matchtemplate_s::type, bot_match_s::type, and bot_match_s::variables.

01435 {
01436     int i;
01437     bot_matchtemplate_t *ms;
01438 
01439     strncpy(match->string, str, MAX_MESSAGE_SIZE);
01440     //remove any trailing enters
01441     while(strlen(match->string) &&
01442             match->string[strlen(match->string)-1] == '\n')
01443     {
01444         match->string[strlen(match->string)-1] = '\0';
01445     } //end while
01446     //compare the string with all the match strings
01447     for (ms = matchtemplates; ms; ms = ms->next)
01448     {
01449         if (!(ms->context & context)) continue;
01450         //reset the match variable offsets
01451         for (i = 0; i < MAX_MATCHVARIABLES; i++) match->variables[i].offset = -1;
01452         //
01453         if (StringsMatch(ms->first, match))
01454         {
01455             match->type = ms->type;
01456             match->subtype = ms->subtype;
01457             return qtrue;
01458         } //end if
01459     } //end for
01460     return qfalse;
01461 } //end of the function BotFindMatch

Here is the call graph for this function:

void BotFreeChatState int  handle  ) 
 

Definition at line 2915 of file be_ai_chat.c.

References bot_chatstate_t, bot_consolemessage_t, botchatstates, BotFreeChatFile(), botimport, BotNextConsoleMessage(), BotRemoveConsoleMessage(), FreeMemory(), h(), LibVarGetValue(), m, and PRT_FATAL.

Referenced by BotShutdownChatAI().

02916 {
02917     bot_chatstate_t *cs;
02918     bot_consolemessage_t m;
02919     int h;
02920 
02921     if (handle <= 0 || handle > MAX_CLIENTS)
02922     {
02923         botimport.Print(PRT_FATAL, "chat state handle %d out of range\n", handle);
02924         return;
02925     } //end if
02926     if (!botchatstates[handle])
02927     {
02928         botimport.Print(PRT_FATAL, "invalid chat state %d\n", handle);
02929         return;
02930     } //end if
02931     cs = botchatstates[handle];
02932     if (LibVarGetValue("bot_reloadcharacters"))
02933     {
02934         BotFreeChatFile(handle);
02935     } //end if
02936     //free all the console messages left in the chat state
02937     for (h = BotNextConsoleMessage(handle, &m); h; h = BotNextConsoleMessage(handle, &m))
02938     {
02939         //remove the console message
02940         BotRemoveConsoleMessage(handle, h);
02941     } //end for
02942     FreeMemory(botchatstates[handle]);
02943     botchatstates[handle] = NULL;
02944 } //end of the function BotFreeChatState

Here is the call graph for this function:

void BotGetChatMessage int  chatstate,
char *  buf,
int  size
 

Definition at line 2821 of file be_ai_chat.c.

References bot_chatstate_t, BotChatStateFromHandle(), BotRemoveTildes(), bot_chatstate_s::chatmessage, strcpy(), and strncpy().

02822 {
02823     bot_chatstate_t *cs;
02824 
02825     cs = BotChatStateFromHandle(chatstate);
02826     if (!cs) return;
02827 
02828     BotRemoveTildes(cs->chatmessage);
02829     strncpy(buf, cs->chatmessage, size-1);
02830     buf[size-1] = '\0';
02831     //clear the chat message from the state
02832     strcpy(cs->chatmessage, "");
02833 } //end of the function BotGetChatMessage

Here is the call graph for this function:

void BotInitialChat int  chatstate,
char *  type,
int  mcontext,
char *  var0,
char *  var1,
char *  var2,
char *  var3,
char *  var4,
char *  var5,
char *  var6,
char *  var7
 

Definition at line 2492 of file be_ai_chat.c.

References bot_chatstate_t, bot_match_t, BotChatStateFromHandle(), BotChooseInitialChatMessage(), BotConstructChatMessage(), botimport, bot_chatstate_s::chat, Com_Memset(), match(), PRT_MESSAGE, qfalse, strcat(), strlen(), and type.

02493 {
02494     char *message;
02495     int index;
02496     bot_match_t match;
02497     bot_chatstate_t *cs;
02498 
02499     cs = BotChatStateFromHandle(chatstate);
02500     if (!cs) return;
02501     //if no chat file is loaded
02502     if (!cs->chat) return;
02503     //choose a chat message randomly of the given type
02504     message = BotChooseInitialChatMessage(cs, type);
02505     //if there's no message of the given type
02506     if (!message)
02507     {
02508 #ifdef DEBUG
02509         botimport.Print(PRT_MESSAGE, "no chat messages of type %s\n", type);
02510 #endif //DEBUG
02511         return;
02512     } //end if
02513     //
02514     Com_Memset(&match, 0, sizeof(match));
02515     index = 0;
02516     if( var0 ) {
02517         strcat(match.string, var0);
02518         match.variables[0].offset = index;
02519         match.variables[0].length = strlen(var0);
02520         index += strlen(var0);
02521     }
02522     if( var1 ) {
02523         strcat(match.string, var1);
02524         match.variables[1].offset = index;
02525         match.variables[1].length = strlen(var1);
02526         index += strlen(var1);
02527     }
02528     if( var2 ) {
02529         strcat(match.string, var2);
02530         match.variables[2].offset = index;
02531         match.variables[2].length = strlen(var2);
02532         index += strlen(var2);
02533     }
02534     if( var3 ) {
02535         strcat(match.string, var3);
02536         match.variables[3].offset = index;
02537         match.variables[3].length = strlen(var3);
02538         index += strlen(var3);
02539     }
02540     if( var4 ) {
02541         strcat(match.string, var4);
02542         match.variables[4].offset = index;
02543         match.variables[4].length = strlen(var4);
02544         index += strlen(var4);
02545     }
02546     if( var5 ) {
02547         strcat(match.string, var5);
02548         match.variables[5].offset = index;
02549         match.variables[5].length = strlen(var5);
02550         index += strlen(var5);
02551     }
02552     if( var6 ) {
02553         strcat(match.string, var6);
02554         match.variables[6].offset = index;
02555         match.variables[6].length = strlen(var6);
02556         index += strlen(var6);
02557     }
02558     if( var7 ) {
02559         strcat(match.string, var7);
02560         match.variables[7].offset = index;
02561         match.variables[7].length = strlen(var7);
02562         index += strlen(var7);
02563     }
02564     //
02565     BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse);
02566 } //end of the function BotInitialChat

Here is the call graph for this function:

int BotLoadChatFile int  chatstate,
char *  chatfile,
char *  chatname
 

Definition at line 2200 of file be_ai_chat.c.

References bot_chatstate_t, BotChatStateFromHandle(), BotFreeChatFile(), botimport, BotLoadInitialChat(), bot_ichatdata_t::chat, bot_chatstate_s::chat, GetClearedMemory(), ichatdata, LibVarGetValue(), n, PRT_FATAL, Q_strncpyz(), and strcmp().

02201 {
02202     bot_chatstate_t *cs;
02203     int n, avail = 0;
02204 
02205     cs = BotChatStateFromHandle(chatstate);
02206     if (!cs) return BLERR_CANNOTLOADICHAT;
02207     BotFreeChatFile(chatstate);
02208 
02209     if (!LibVarGetValue("bot_reloadcharacters"))
02210     {
02211         avail = -1;
02212         for( n = 0; n < MAX_CLIENTS; n++ ) {
02213             if( !ichatdata[n] ) {
02214                 if( avail == -1 ) {
02215                     avail = n;
02216                 }
02217                 continue;
02218             }
02219             if( strcmp( chatfile, ichatdata[n]->filename ) != 0 ) { 
02220                 continue;
02221             }
02222             if( strcmp( chatname, ichatdata[n]->chatname ) != 0 ) { 
02223                 continue;
02224             }
02225             cs->chat = ichatdata[n]->chat;
02226         //      botimport.Print( PRT_MESSAGE, "retained %s from %s\n", chatname, chatfile );
02227             return BLERR_NOERROR;
02228         }
02229 
02230         if( avail == -1 ) {
02231             botimport.Print(PRT_FATAL, "ichatdata table full; couldn't load chat %s from %s\n", chatname, chatfile);
02232             return BLERR_CANNOTLOADICHAT;
02233         }
02234     }
02235 
02236     cs->chat = BotLoadInitialChat(chatfile, chatname);
02237     if (!cs->chat)
02238     {
02239         botimport.Print(PRT_FATAL, "couldn't load chat %s from %s\n", chatname, chatfile);
02240         return BLERR_CANNOTLOADICHAT;
02241     } //end if
02242     if (!LibVarGetValue("bot_reloadcharacters"))
02243     {
02244         ichatdata[avail] = GetClearedMemory( sizeof(bot_ichatdata_t) );
02245         ichatdata[avail]->chat = cs->chat;
02246         Q_strncpyz( ichatdata[avail]->chatname, chatname, sizeof(ichatdata[avail]->chatname) );
02247         Q_strncpyz( ichatdata[avail]->filename, chatfile, sizeof(ichatdata[avail]->filename) );
02248     } //end if
02249 
02250     return BLERR_NOERROR;
02251 } //end of the function BotLoadChatFile

Here is the call graph for this function:

void BotMatchVariable bot_match_t match,
int  variable,
char *  buf,
int  size
 

Definition at line 1468 of file be_ai_chat.c.

References assert, bot_match_t, botimport, bot_matchvariable_s::length, match(), bot_matchvariable_s::offset, PRT_FATAL, strcpy(), bot_match_s::string, strncpy(), and bot_match_s::variables.

01469 {
01470     if (variable < 0 || variable >= MAX_MATCHVARIABLES)
01471     {
01472         botimport.Print(PRT_FATAL, "BotMatchVariable: variable out of range\n");
01473         strcpy(buf, "");
01474         return;
01475     } //end if
01476 
01477     if (match->variables[variable].offset >= 0)
01478     {
01479         if (match->variables[variable].length < size)
01480             size = match->variables[variable].length+1;
01481         assert( match->variables[variable].offset >= 0 ); // bk001204
01482         strncpy(buf, &match->string[ (int) match->variables[variable].offset], size-1);
01483         buf[size-1] = '\0';
01484     } //end if
01485     else
01486     {
01487         strcpy(buf, "");
01488     } //end else
01489     return;
01490 } //end of the function BotMatchVariable

Here is the call graph for this function:

int BotNextConsoleMessage int  chatstate,
bot_consolemessage_t cm
 

Definition at line 367 of file be_ai_chat.c.

References bot_chatstate_t, bot_consolemessage_t, BotChatStateFromHandle(), cm, Com_Memcpy(), and bot_chatstate_s::firstmessage.

Referenced by BotFreeChatState().

00368 {
00369     bot_chatstate_t *cs;
00370 
00371     cs = BotChatStateFromHandle(chatstate);
00372     if (!cs) return 0;
00373     if (cs->firstmessage)
00374     {
00375         Com_Memcpy(cm, cs->firstmessage, sizeof(bot_consolemessage_t));
00376         cm->next = cm->prev = NULL;
00377         return cm->handle;
00378     } //end if
00379     return 0;
00380 } //end of the function BotConsoleMessage

Here is the call graph for this function:

int BotNumConsoleMessages int  chatstate  ) 
 

Definition at line 387 of file be_ai_chat.c.

References bot_chatstate_t, BotChatStateFromHandle(), and bot_chatstate_s::numconsolemessages.

00388 {
00389     bot_chatstate_t *cs;
00390 
00391     cs = BotChatStateFromHandle(chatstate);
00392     if (!cs) return 0;
00393     return cs->numconsolemessages;
00394 } //end of the function BotNumConsoleMessages

Here is the call graph for this function:

int BotNumInitialChats int  chatstate,
char *  type
 

Definition at line 2465 of file be_ai_chat.c.

References bot_chatstate_t, bot_chattype_t, BotChatStateFromHandle(), botimport, bot_chatstate_s::chat, LibVarGetValue(), bot_chattype_s::name, bot_chattype_s::next, bot_chattype_s::numchatmessages, PRT_MESSAGE, Q_stricmp(), t, type, and bot_chat_s::types.

02466 {
02467     bot_chatstate_t *cs;
02468     bot_chattype_t *t;
02469 
02470     cs = BotChatStateFromHandle(chatstate);
02471     if (!cs) return 0;
02472 
02473     for (t = cs->chat->types; t; t = t->next)
02474     {
02475         if (!Q_stricmp(t->name, type))
02476         {
02477             if (LibVarGetValue("bot_testichat")) {
02478                 botimport.Print(PRT_MESSAGE, "%s has %d chat lines\n", type, t->numchatmessages);
02479                 botimport.Print(PRT_MESSAGE, "-------------------\n");
02480             }
02481             return t->numchatmessages;
02482         } //end if
02483     } //end for
02484     return 0;
02485 } //end of the function BotNumInitialChats

Here is the call graph for this function:

void BotQueueConsoleMessage int  chatstate,
int  type,
char *  message
 

Definition at line 326 of file be_ai_chat.c.

References AAS_Time(), AllocConsoleMessage(), bot_chatstate_t, bot_consolemessage_t, BotChatStateFromHandle(), botimport, bot_chatstate_s::firstmessage, bot_consolemessage_s::handle, bot_chatstate_s::handle, bot_chatstate_s::lastmessage, m, MAX_MESSAGE_SIZE, bot_consolemessage_s::message, bot_consolemessage_s::next, bot_chatstate_s::numconsolemessages, bot_consolemessage_s::prev, PRT_ERROR, strncpy(), bot_consolemessage_s::time, and bot_consolemessage_s::type.

00327 {
00328     bot_consolemessage_t *m;
00329     bot_chatstate_t *cs;
00330 
00331     cs = BotChatStateFromHandle(chatstate);
00332     if (!cs) return;
00333 
00334     m = AllocConsoleMessage();
00335     if (!m)
00336     {
00337         botimport.Print(PRT_ERROR, "empty console message heap\n");
00338         return;
00339     } //end if
00340     cs->handle++;
00341     if (cs->handle <= 0 || cs->handle > 8192) cs->handle = 1;
00342     m->handle = cs->handle;
00343     m->time = AAS_Time();
00344     m->type = type;
00345     strncpy(m->message, message, MAX_MESSAGE_SIZE);
00346     m->next = NULL;
00347     if (cs->lastmessage)
00348     {
00349         cs->lastmessage->next = m;
00350         m->prev = cs->lastmessage;
00351         cs->lastmessage = m;
00352     } //end if
00353     else
00354     {
00355         cs->lastmessage = m;
00356         cs->firstmessage = m;
00357         m->prev = NULL;
00358     } //end if
00359     cs->numconsolemessages++;
00360 } //end of the function BotQueueConsoleMessage

Here is the call graph for this function:

void BotRemoveConsoleMessage int  chatstate,
int  handle
 

Definition at line 296 of file be_ai_chat.c.

References bot_chatstate_t, bot_consolemessage_t, BotChatStateFromHandle(), bot_chatstate_s::firstmessage, FreeConsoleMessage(), bot_consolemessage_s::handle, bot_chatstate_s::lastmessage, m, bot_consolemessage_s::next, bot_chatstate_s::numconsolemessages, and bot_consolemessage_s::prev.

Referenced by BotFreeChatState().

00297 {
00298     bot_consolemessage_t *m, *nextm;
00299     bot_chatstate_t *cs;
00300 
00301     cs = BotChatStateFromHandle(chatstate);
00302     if (!cs) return;
00303 
00304     for (m = cs->firstmessage; m; m = nextm)
00305     {
00306         nextm = m->next;
00307         if (m->handle == handle)
00308         {
00309             if (m->next) m->next->prev = m->prev;
00310             else cs->lastmessage = m->prev;
00311             if (m->prev) m->prev->next = m->next;
00312             else cs->firstmessage = m->next;
00313 
00314             FreeConsoleMessage(m);
00315             cs->numconsolemessages--;
00316             break;
00317         } //end if
00318     } //end for
00319 } //end of the function BotRemoveConsoleMessage

Here is the call graph for this function:

void BotReplaceSynonyms char *  string,
unsigned long int  context
 

Definition at line 761 of file be_ai_chat.c.

References bot_synonym_t, bot_synonymlist_t, bot_synonymlist_s::context, bot_synonymlist_s::firstsynonym, bot_synonym_s::next, bot_synonymlist_s::next, bot_synonym_s::string, string(), and StringReplaceWords().

Referenced by BotExpandChatMessage().

00762 {
00763     bot_synonymlist_t *syn;
00764     bot_synonym_t *synonym;
00765 
00766     for (syn = synonyms; syn; syn = syn->next)
00767     {
00768         if (!(syn->context & context)) continue;
00769         for (synonym = syn->firstsynonym->next; synonym; synonym = synonym->next)
00770         {
00771             StringReplaceWords(string, synonym->string, syn->firstsynonym->string);
00772         } //end for
00773     } //end for
00774 } //end of the function BotReplaceSynonyms

Here is the call graph for this function:

int BotReplyChat int  chatstate,
char *  message,
int  mcontext,
int  vcontext,
char *  var0,
char *  var1,
char *  var2,
char *  var3,
char *  var4,
char *  var5,
char *  var6,
char *  var7
 

Definition at line 2614 of file be_ai_chat.c.

References AAS_Time(), bot_chatmessage_t, bot_chatstate_t, bot_match_t, bot_replychat_t, bot_replychatkey_t, BotChatStateFromHandle(), BotConstructChatMessage(), botimport, BotRemoveTildes(), bot_chatstate_s::chatmessage, bot_chatmessage_s::chatmessage, Com_Memcpy(), Com_Memset(), bot_replychat_s::firstchatmessage, bot_replychatkey_s::flags, bot_chatstate_s::gender, bot_replychat_s::keys, bot_matchvariable_s::length, LibVarGetValue(), m, bot_replychatkey_s::match, match(), bot_chatstate_s::name, bot_chatmessage_s::next, bot_replychatkey_s::next, bot_replychat_s::next, bot_matchvariable_s::offset, bot_replychat_s::priority, PRT_MESSAGE, qfalse, qtrue, random, strcat(), strcpy(), bot_replychatkey_s::string, bot_match_s::string, StringContains(), StringContainsWord(), StringsMatch(), strlen(), bot_chatmessage_s::time, and bot_match_s::variables.

02615 {
02616     bot_replychat_t *rchat, *bestrchat;
02617     bot_replychatkey_t *key;
02618     bot_chatmessage_t *m, *bestchatmessage;
02619     bot_match_t match, bestmatch;
02620     int bestpriority, num, found, res, numchatmessages, index;
02621     bot_chatstate_t *cs;
02622 
02623     cs = BotChatStateFromHandle(chatstate);
02624     if (!cs) return qfalse;
02625     Com_Memset(&match, 0, sizeof(bot_match_t));
02626     strcpy(match.string, message);
02627     bestpriority = -1;
02628     bestchatmessage = NULL;
02629     bestrchat = NULL;
02630     //go through all the reply chats
02631     for (rchat = replychats; rchat; rchat = rchat->next)
02632     {
02633         found = qfalse;
02634         for (key = rchat->keys; key; key = key->next)
02635         {
02636             res = qfalse;
02637             //get the match result
02638             if (key->flags & RCKFL_NAME) res = (StringContains(message, cs->name, qfalse) != -1);
02639             else if (key->flags & RCKFL_BOTNAMES) res = (StringContains(key->string, cs->name, qfalse) != -1);
02640             else if (key->flags & RCKFL_GENDERFEMALE) res = (cs->gender == CHAT_GENDERFEMALE);
02641             else if (key->flags & RCKFL_GENDERMALE) res = (cs->gender == CHAT_GENDERMALE);
02642             else if (key->flags & RCKFL_GENDERLESS) res = (cs->gender == CHAT_GENDERLESS);
02643             else if (key->flags & RCKFL_VARIABLES) res = StringsMatch(key->match, &match);
02644             else if (key->flags & RCKFL_STRING) res = (StringContainsWord(message, key->string, qfalse) != NULL);
02645             //if the key must be present
02646             if (key->flags & RCKFL_AND)
02647             {
02648                 if (!res)
02649                 {
02650                     found = qfalse;
02651                     break;
02652                 } //end if
02653             } //end else if
02654             //if the key must be absent
02655             else if (key->flags & RCKFL_NOT)
02656             {
02657                 if (res)
02658                 {
02659                     found = qfalse;
02660                     break;
02661                 } //end if
02662             } //end if
02663             else if (res)
02664             {
02665                 found = qtrue;
02666             } //end else
02667         } //end for
02668         //
02669         if (found)
0