Skip to content

Commit

Permalink
Reverted bot-chat attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
APGRoboCop committed Jan 28, 2022
1 parent 096d7bf commit a47d350
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ if cxx.like('gcc'):

if builder.options.opt == '1':
cxx.cflags += ['-O2','-pipe']
#cxx.cflags -= ['-g','-ggdb3']

if builder.options.debug == '1':
cxx.cflags += ['-g','-ggdb3']
Expand Down
6 changes: 3 additions & 3 deletions bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define BOT_H

#include "osdep.h"
#include <string>
#include <cstring>

// stuff for Win32 vs. Linux builds

Expand Down Expand Up @@ -159,10 +159,10 @@ template <typename U> void bzero(U *ptr, size_t len) noexcept {
class chatClass {
private:
// section header names for each chat type, as used in the chat file
std::string sectionNames[TOTAL_CHAT_TYPES];
char sectionNames[TOTAL_CHAT_TYPES][64];

// chat strings, organised by groups of chat types
std::string strings[TOTAL_CHAT_TYPES][MAX_CHAT_STRINGS];
char strings[TOTAL_CHAT_TYPES][MAX_CHAT_STRINGS][512];

// counts the number of strings read from the chat file
int stringCount[TOTAL_CHAT_TYPES];
Expand Down
27 changes: 13 additions & 14 deletions dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,22 +681,21 @@ void GameDLLInit() {

// Constructor for the chatClass class
// sets up the names of the chat section headers
chatClass::chatClass()
{
this->sectionNames[CHAT_TYPE_GREETING] = "[GREETINGS]";
this->sectionNames[CHAT_TYPE_KILL_HI] = "[KILL WINNING]";
this->sectionNames[CHAT_TYPE_KILL_LOW] = "[KILL LOSING]";
this->sectionNames[CHAT_TYPE_KILLED_HI] = "[KILLED WINNING]";
this->sectionNames[CHAT_TYPE_KILLED_LOW] = "[KILLED LOSING]";
this->sectionNames[CHAT_TYPE_SUICIDE] = "[SUICIDE]";
chatClass::chatClass() {
strcpy(this->sectionNames[CHAT_TYPE_GREETING], "[GREETINGS]");
strcpy(this->sectionNames[CHAT_TYPE_KILL_HI], "[KILL WINNING]");
strcpy(this->sectionNames[CHAT_TYPE_KILL_LOW], "[KILL LOSING]");
strcpy(this->sectionNames[CHAT_TYPE_KILLED_HI], "[KILLED WINNING]");
strcpy(this->sectionNames[CHAT_TYPE_KILLED_LOW], "[KILLED LOSING]");
strcpy(this->sectionNames[CHAT_TYPE_SUICIDE], "[SUICIDE]");

int i, j;
int j;

// explicitly clear all the chat strings
for (i = 0; i < TOTAL_CHAT_TYPES; i++) {
for (int i = 0; i < TOTAL_CHAT_TYPES; i++) {
this->stringCount[i] = 0;
for (j = 0; j < MAX_CHAT_STRINGS; j++) {
this->strings[i][j] = "";
this->strings[i][j][0] = 0x0;
}

for (j = 0; j < 5; j++) {
Expand Down Expand Up @@ -757,7 +756,7 @@ void chatClass::readChatFile() {
if (chat_section != -1 && this->stringCount[chat_section] < MAX_CHAT_STRINGS && length > 0) {
// UTIL_BotLogPrintf("buffer %s %d\n", buffer, this->stringCount[chat_section]);

this->strings[chat_section][this->stringCount[chat_section]] = buffer;
strcpy(this->strings[chat_section][this->stringCount[chat_section]], buffer);
++this->stringCount[chat_section];
}
}
Expand Down Expand Up @@ -802,8 +801,8 @@ void chatClass::pickRandomChatString(char *msg, size_t maxLength, const int chat

// set up the message string
// is "%s" in the text?
if (playerName != nullptr && strstr(this->strings[chatSection][randomIndex].c_str(), "%s") != nullptr) {
snprintf(msg, maxLength, this->strings[chatSection][randomIndex].c_str(), playerName);
if (playerName != nullptr && strstr(this->strings[chatSection][randomIndex], "%s") != nullptr) {
snprintf(msg, maxLength, this->strings[chatSection][randomIndex], playerName);
} else
printf("%s", msg);

Expand Down
4 changes: 2 additions & 2 deletions hlsdk/engine/progdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct
float force_retouch;
string_t mapname;
string_t startspot;
bool deathmatch;
float deathmatch;
float coop;
float teamplay;
float serverflags;
Expand Down Expand Up @@ -223,4 +223,4 @@ typedef struct entvars_s
} entvars_t;


#endif // PROGDEFS_H
#endif // PROGDEFS_H

0 comments on commit a47d350

Please sign in to comment.