-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMegaHAL.hpp
759 lines (602 loc) · 18.9 KB
/
MegaHAL.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
//
// Copyright © 2003-2010, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// MegaHAL.hpp
//
// Version: $ID:$
//
#ifndef MEGAHAL_INCLUDED
#define MEGAHAL_INCLUDED
#define BOT_CHAT_MESSAGE_LENGTH 128u
// HAL-related structure definitions
struct HAL_STRING
{
unsigned char length; // length of word (for quick access)
char *word; // the string itself
};
struct HAL_DICTIONARY
{
unsigned long size; // size of dictionary (for quick access)
HAL_STRING *entry; // string entry at this position of the dictionary
unsigned short *index; // pointer to index
};
struct HAL_SWAP
{
unsigned short size; // size of the word swap structure
HAL_STRING *from; // word to be changed into the next
HAL_STRING *to; // word for replacing the previous
};
typedef struct HAL_NODE
{
unsigned short symbol; // symbol ID
unsigned long usage; // usage information
unsigned short count; // usage count (?)
unsigned short branch; // branch of the tree
struct HAL_NODE **tree; // pointer to tree node pointer
} HAL_TREE;
struct HAL_MODEL
{
unsigned char order; // model order (complexity)
HAL_TREE *forward; // pointer to the model's forward tree
HAL_TREE *backward; // pointer to the model's backwards tree
HAL_TREE **context; // pointer to context tree pointer
HAL_DICTIONARY *dictionary; // pointer to the model's dictionary
};
struct HAL_bot_t
{
HAL_DICTIONARY *banned_keywords; // dictionary of words that must never be used as keywords
HAL_DICTIONARY *auxiliary_keywords; // dictionary of auxiliary keywords
HAL_SWAP *swappable_keywords; // array of swappable keywords with their equivalences
HAL_MODEL *bot_model; // Markov model of the bot
HAL_DICTIONARY *input_words; // global chat's dictionary of words
// HAL_DICTIONARY *bot_words; // bot's own dictionary of words
bool keyword_is_used;
};
// bot HAL Markov model order
#define BOT_HAL_MODEL_ORDER 5
void HumanizeString (char *string);
void RemoveNameTags (const char *in_string, char *out_string);
void BotChat (YaPB *pBot);
void BotSayText (YaPB *pBot);
void BotSayAudio (YaPB *pBot);
void BotTalk (YaPB *pBot, char *sound_path);
void HAL_LoadTree (FILE *file, HAL_TREE *node);
void HAL_LoadDictionary (FILE *file, HAL_DICTIONARY *dictionary);
void HAL_SaveTree (FILE *file, HAL_TREE *node);
void HAL_SaveDictionary (FILE *file, HAL_DICTIONARY *dictionary);
void HAL_Learn (HAL_MODEL *model, HAL_DICTIONARY *words);
unsigned short HAL_AddWord (HAL_DICTIONARY *dictionary, HAL_STRING word);
int HAL_SearchDictionary (HAL_DICTIONARY *dictionary, HAL_STRING word, bool &find);
unsigned short HAL_FindWord (HAL_DICTIONARY *dictionary, HAL_STRING word);
int HAL_CompareWords (HAL_STRING word1, HAL_STRING word2);
void HAL_InitializeDictionary (HAL_DICTIONARY *dictionary);
HAL_DICTIONARY *HAL_NewDictionary (void);
HAL_TREE *HAL_NewNode (void);
HAL_MODEL *HAL_NewModel (int order);
void HAL_UpdateModel (HAL_MODEL *model, int symbol);
void HAL_UpdateContext (HAL_MODEL *model, int symbol);
HAL_TREE *HAL_AddSymbol (HAL_TREE *tree, unsigned short symbol);
HAL_TREE *HAL_FindSymbol (HAL_TREE *node, int symbol);
HAL_TREE *HAL_FindSymbolAdd (HAL_TREE *node, int symbol);
void HAL_AddNode (HAL_TREE *tree, HAL_TREE *node, int position);
int HAL_SearchNode (HAL_TREE *node, int symbol, bool *found_symbol);
void HAL_InitializeContext (HAL_MODEL *model);
void BotHALTrainModel (YaPB *pBot, HAL_MODEL *model);
void HAL_ShowDictionary (HAL_DICTIONARY *dictionary);
void HAL_MakeWords (char *input, HAL_DICTIONARY *words);
void BotHALGenerateReply (YaPB *pBot, char *output);
bool HAL_BoundaryExists (const char *string, int position);
void BotChatReply (YaPB *pBot, char *szMsg, HalfLifeEngine::SDK::Classes::Edict *pSender, char *szReplyMsg);
bool HAL_DictionariesDiffer (HAL_DICTIONARY *words1, HAL_DICTIONARY *words2);
HAL_DICTIONARY *BotHALMakeKeywords (YaPB *pBot, HAL_DICTIONARY *words);
void BotHALAddKeyword (YaPB *pBot, HAL_DICTIONARY *keys, HAL_STRING word);
void BotHALAddAuxiliaryKeyword (YaPB *pBot, HAL_DICTIONARY *keys, HAL_STRING word);
HAL_DICTIONARY *BotHALBuildReplyDictionary (YaPB *pBot, HAL_DICTIONARY *keys);
int BotHALBabble (YaPB *pBot, HAL_DICTIONARY *keys, HAL_DICTIONARY *words);
bool HAL_WordExists (HAL_DICTIONARY *dictionary, HAL_STRING word);
int BotHALSeedReply (YaPB *pBot, HAL_DICTIONARY *keys);
HAL_SWAP *HAL_NewSwap (void);
void HAL_AddSwap (HAL_SWAP *list, char *s, char *d);
HAL_SWAP *HAL_InitializeSwap (char *filename);
HAL_DICTIONARY *HAL_InitializeList (char *filename);
void HAL_EmptyDictionary (HAL_DICTIONARY *dictionary);
void HAL_FreeModel (HAL_MODEL *model);
void HAL_FreeTree (HAL_TREE *tree);
void HAL_FreeSwap (HAL_SWAP *swap);
inline const int strpos (const char *pos, const char *start)
{
return ((int)pos - (int)start);
}
// Fill string, a neat function I made
// fills the points of a string with %l, %r, %whatever with readable text
inline const bool BotFunc_FillString (char *string, const char *fill_point, const char *fill_with, int max_len)
{
// keep a big string to make sure everything fits
static char temp[1024];
int len = GetStringLength <unsigned short> (string) + 1;
int start;
int end;
char *ptr = NULL;
// store before and after strings, well put these in the final string
char *before;
char *after;
if (fill_with == NULL)
return false;
ptr = string;
// Keep searching for a point in the string
while ((ptr = strstr (ptr, fill_point)) != NULL)
{
// found a point
before = new char[len];
after = new char[len];
// initialize them to empty (don't need to null terminate at the right point)
memset (before, '\0', len);
memset (after, '\0', len);
start = strpos (ptr, string);
strncpy(before,string,start);
// always null terminate the last possible character
string[start] = '\0';
end = start + GetStringLength <unsigned short> (fill_point);
strncpy (after, string + end, len - end);
after[len - end] = '\0';
// fill in new string and..
// update len (string size may have INCREASED
// if by more than 2* normal string size, could have overwritten
// some precious memory!)
len = sprintf (temp, "%s%s%s", before, fill_with, after);
// fill string now with maximum length for string
strncpy (string, temp, max_len - 1);
string[max_len - 1] = '\0';
// MUST reset ptr incase new ptr is outside the string (if string size was reduced)
ptr = string;
// free memory used
delete [] before;
delete [] after;
/*
int len = GetStringLength <unsigned short> (ptr + 2);
temp = NULL;
if (len > 0)
{
// allocate the string size, will use less space and wont crash if too big :p
temp = new char[len + 1];
strcpy (temp, ptr + 2);
}
string[strpos (ptr, string)] = '\0';
strcat (string, fill_with);
if (temp != NULL)
{
strcat (string, temp);
delete [] temp;
}*/
}
return true; // no point found (nothing to add) return true (string can be used)
}
//////////////////////////////////////////////////////////
// REPUTATION DEFINITIONS
#define BOT_MIN_REP 0
#define BOT_LOW_REP 3
#define BOT_MID_REP 5
#define BOT_HIGH_REP 6
#define BOT_MAX_REP 10
#if 0
/////////////////////////////////////////////
// REPUTATION STORAGE CLASSES
class CBotReputation
{
public:
//////////////////////////////////////////////////////////
// REPUTATION DEFINITIONS
#define BOT_MIN_REP 0
#define BOT_LOW_REP 3
#define BOT_MID_REP 5
#define BOT_HIGH_REP 6
#define BOT_MAX_REP 10
private:
int m_iPlayerRepId;
int m_iRep;
public:
CBotReputation()
{
m_iRep = BOT_MID_REP;
m_iPlayerRepId = -1;
}
CBotReputation( int iPlayerRepId, int iRep )
{
m_iPlayerRepId = iPlayerRepId;
m_iRep = iRep;
}
public:
bool operator == (CBotReputation Rep)
{
return Rep.IsForPlayer(m_iPlayerRepId);
}
public:
inline void UpdateRep(int iRep)
{
m_iRep = iRep;
}
inline int CurrentRep ( void )
{
return m_iRep;
}
inline int GetRepId ( void )
{
return m_iPlayerRepId;
}
inline bool IsForPlayer ( int iPlayerRepId )
{
return m_iPlayerRepId == iPlayerRepId;
}
void printRep ( YaPB *forBot, HalfLifeEngine::SDK::Classes::Edict *pPrintTo )
{
Client *pClient = gBotGlobals.m_Clients.GetClientByRepId(m_iPlayerRepId);
switch ( m_iRep )
{
case 0:
BotMessage(pPrintTo,0,"%s really hates %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 1:
BotMessage(pPrintTo,0,"%s hates %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 2:
BotMessage(pPrintTo,0,"%s kind of hates %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 3:
BotMessage(pPrintTo,0,"%s doesn't like %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 4:
case 5:
case 6:
BotMessage(pPrintTo,0,"%s likes %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 7:
BotMessage(pPrintTo,0,"%s really likes %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 8:
BotMessage(pPrintTo,0,"%s loves %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 9:
BotMessage(pPrintTo,0,"%s really loves %s (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
case 10:
BotMessage(pPrintTo,0,"%s LURRVESS %s !!! (%d)",forBot->GetName ().GetData (),pClient->GetName ().GetData (),m_iRep);
break;
}
}
};
class CBotReputations
{
private:
dataStack<CBotReputation> m_RepList;
public:
void printReps ( YaPB *forBot, HalfLifeEngine::SDK::Classes::Edict *pPrintTo )
{
dataStack<CBotReputation> tempStack = m_RepList;
CBotReputation *pRep;
while ( !tempStack.IsEmpty() )
{
pRep = tempStack.ChoosePointerFromStack();
pRep->printRep(forBot,pPrintTo);
}
}
void Destroy ( void )
{
m_RepList.Destroy();
}
Client *GetRandomClient ( int iRep )
// return a random client that conforms to the iRep (reputation)
// -1 will return a random bad client
// 0 : a random neutral client
// 1 : a random friendly client
{
int iGotRep;
dataStack <CBotReputation> tempStack = m_RepList;
CBotReputation *pRep;
dataUnconstArray<CBotReputation*> iIdList;
iIdList.Init();
while ( !tempStack.IsEmpty() )
{
pRep = tempStack.ChoosePointerFromStack();
iGotRep = pRep->CurrentRep();
switch ( iRep )
{
case -1: // bad
if ( iGotRep <= 3 )
iIdList.Add(pRep);
break;
case 0: // neutral
if (( iGotRep > 3 ) && ( iGotRep < 7 ))
iIdList.Add(pRep);
break;
case 1: // good
if ( iGotRep >= 7 )
iIdList.Add(pRep);
break;
}
}
tempStack.Init();
if ( iIdList.IsEmpty() )
return NULL;
assert ( iIdList.Size() > 0 );
pRep = iIdList.Random();
iIdList.Clear();
if ( pRep == NULL )
return NULL;
return gBotGlobals.m_Clients.GetClientByRepId(pRep->GetRepId());
}
void WriteToFile (int iBotProfile, CBotReputation *pRep)
{
FILE *fp;
char filename[256];
char repfile[16];
CBotReputation Rep;
bool bChanged = false;
if ( pRep == NULL ) // error
return;
sprintf(repfile,"%d.rcr",iBotProfile);
UTIL_BuildFileName(filename,BOT_PROFILES_FOLDER,repfile);
fp = fopen (filename, "rb+"); // open the file in ascii read/write mode
if ( fp == NULL )
{
fp = fopen (filename, "wb");
if ( fp == NULL )
{
BotMessage(NULL,0,"could not save Bot id %d's rep file", iBotProfile);
return;
}
fwrite(pRep,sizeof(CBotReputation),1,fp);
fclose(fp);
return;
}
fseek(fp,0,SEEK_END); // move pos to end of file
long fPos = ftell(fp); // get length of file
// do some error checking - verify the file is not corrupt
if (fPos%sizeof(CBotReputation)!=0)
return;
// get the count of items in the file
long count = fPos/sizeof(CBotReputation);
fseek(fp,0,SEEK_SET); // move pos back to beginning
while (bChanged == false && !feof(fp) && count>0)
{
fread(&Rep,sizeof(CBotReputation),1,fp);
if ( Rep == *pRep )
{
fPos = ftell(fp); // get the current position
// move marker back to start of this record
fseek(fp,0-sizeof(CBotReputation),SEEK_CUR);
fwrite(pRep,sizeof(CBotReputation),1,fp);
fflush(fp);
// now reset the marker to same as before we
// deleted this record so that everything continues
// as normal
fseek(fp,fPos,SEEK_SET);
bChanged = true;
}
--count;
}
fclose(fp);
if ( bChanged == false )
{
fp = fopen(filename,"ab"); // append binary
if ( fp == NULL )
{
BotMessage(NULL,0,"Can't open reputation file \"%s\" for appending",filename);
return; // error
}
else
{
fwrite(pRep,sizeof(CBotReputation),1,fp);
fclose(fp);
}
}
}
// Saves ONE rep and removes it
void RemoveSaveRep ( int iBotProfile, int iPlayerRepId )
{
CBotReputation *pRep = GetRep(iPlayerRepId);
if ( pRep )
{
WriteToFile(iBotProfile,pRep);
}
m_RepList.RemoveByPointer(pRep);
}
// Saves ALL rep
void SaveAllRep ( int iBotProfile )
{
dataStack <CBotReputation> tempStack = m_RepList;
CBotReputation *pRep;
while ( !tempStack.IsEmpty() )
{
pRep = tempStack.ChoosePointerFromStack();
if ( pRep )
WriteToFile(iBotProfile,pRep);
}
return;
}
void AddLoadRep ( int iBotProfile, int iPlayerRepId )
{
FILE *fp;
char filename[256];
char repfile[16];
CBotReputation Rep;
bool bFound = false;
sprintf(repfile,"%d.rcr",iBotProfile);
UTIL_BuildFileName(filename,BOT_PROFILES_FOLDER,repfile);
fp = fopen (filename, "rb"); // open the file in ascii read/write mode
if ( fp == NULL )
{
m_RepList.Push(CBotReputation(iPlayerRepId,BOT_MID_REP));
WriteToFile(iBotProfile,m_RepList.GetHeadInfoPointer());
return;
}
fseek(fp,0,SEEK_END); // move pos to end of file
long fPos = ftell(fp); // get length of file
// do some error checking - verify the file is not corrupt
if (fPos%sizeof(CBotReputation)!=0) return;
// get the count of items in the file
long count = fPos/sizeof(CBotReputation);
fseek(fp,0,SEEK_SET); // move pos back to beginning
while ((bFound == false) && !feof(fp) && count>0)
{
fread(&Rep,sizeof(CBotReputation),1,fp);
// is for the player input into function (player id)?
if ( Rep.IsForPlayer(iPlayerRepId) )
{
m_RepList.Push(Rep);
bFound = true;
}
--count;
}
fclose(fp);
if ( bFound == false )
{
m_RepList.Push(CBotReputation(iPlayerRepId,BOT_MID_REP));
// save new
WriteToFile(iBotProfile,m_RepList.GetHeadInfoPointer());
}
return;
}
void NewRep (int iPlayerRepId)
// Create a NEW Reputation value for player name szPlayerName
// With a default Rep of a Mid way rep.
{
AddRep(iPlayerRepId,BOT_MID_REP);
}
int AverageRepOnServer ( void )
{
int iTotal = 0;
int iNum = 0;
if ( m_RepList.IsEmpty() )
return 0;
dataStack<CBotReputation> tempStack = m_RepList;
CBotReputation *pRep;
while ( !tempStack.IsEmpty() )
{
pRep = tempStack.ChoosePointerFromStack();
// bug fixed... didn't add :-P
iTotal += pRep->CurrentRep ();
++iNum;
}
return iTotal / iNum;
}
void AddRep ( int iPlayerRepId ,int iRep)
// Add a NEW Reputation WITH a reputation value
{
CBotReputation *l_Rep;
l_Rep = GetRep(iPlayerRepId);
if ( l_Rep == NULL ) // Don't want to add a duplicate
m_RepList.Push(CBotReputation(iPlayerRepId,iRep));
}
CBotReputation *GetCreateRep ( int iPlayerRepId )
{
dataStack<CBotReputation> tempStack = m_RepList;
CBotReputation *l_Rep;
while ( !tempStack.IsEmpty() )
{
l_Rep = tempStack.ChoosePointerFromStack();
if ( l_Rep->IsForPlayer(iPlayerRepId) )
{
// Fool pointer, dont free memory
tempStack.Init ();
return l_Rep;
}
}
m_RepList.Push(CBotReputation(iPlayerRepId,BOT_MID_REP));
return m_RepList.GetHeadInfoPointer();
}
CBotReputation *GetRep ( int iPlayerRepId )
{
dataStack<CBotReputation> tempStack = m_RepList;
CBotReputation *l_Rep;
while ( !tempStack.IsEmpty() )
{
l_Rep = tempStack.ChoosePointerFromStack();
if ( l_Rep->IsForPlayer(iPlayerRepId) )
{
// Fool pointer, dont free memory
tempStack.Init();
return l_Rep;
}
}
return NULL;
}
int GetClientRep ( Client *pClient )
{
if ( pClient == NULL )
{
BotMessage(NULL,0,"warning: GetClientRep(): Bad pClient recieved (NULL) (returning default)");
return BOT_MID_REP;
}
int iRepId = pClient->GetPlayerRepId();
if ( iRepId == -1 )
return BOT_MID_REP;
CBotReputation *pRep = GetRep(iRepId);
if ( pRep == NULL )
{
BotMessage(NULL,0,"warning: GetClientRep(): No Rep for pClient (id: %d) (returning default)",pClient->GetPlayerRepId());
return BOT_MID_REP;
}
return pRep->CurrentRep();
}
void IncreaseRep( int iPlayerRepId )
{
if ( iPlayerRepId == -1 )
return;
CBotReputation *l_Rep = GetRep(iPlayerRepId);
if ( l_Rep )
{
int iNewRep = l_Rep->CurrentRep()+1;
if ( iNewRep > BOT_MAX_REP )
return;
l_Rep->UpdateRep(iNewRep);
}
else
{
// oh crap wth?
BugMessage(NULL,"bad rep data... (try deleting all " BOT_PROFILES_FOLDER "/*.rcr files :-( )");
}
}
void DecreaseRep( int iPlayerRepId )
{
if ( iPlayerRepId == -1 )
return;
CBotReputation *l_Rep = GetRep(iPlayerRepId);
if ( l_Rep )
{
int iNewRep = l_Rep->CurrentRep()-1;
if ( iNewRep < BOT_MIN_REP )
return;
l_Rep->UpdateRep(iNewRep);
}
else
{
// oh crap wth?
BugMessage(NULL,"bad rep data... (try deleting all " BOT_PROFILES_FOLDER "/*.rcr files :-( )");
}
}
void Init ( void )
{
m_RepList.Init();
}
};
#endif // if 0
void ReplyToMessage (YaPB *const bot, char *szMessage, Client *pSender, const bool iTeamOnly);
#endif // ifndef MEGAHAL_INCLUDED