Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deps/botlib/be_aas_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,10 @@ int AAS_ClipToBBox(aas_trace_t *trace, vec3_t start, vec3_t end, int presencetyp
// Returns: aas_clientmove_t
// Changes Globals: -
//===========================================================================
int AAS_ClientMovementPrediction(struct aas_clientmove_s *move, int entnum, vec3_t origin, int presencetype,
int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes,
float frametime, int stopevent, int stopareanum, vec3_t mins, vec3_t maxs,
int visualize, int jumper) {
int AAS_ClientMovementPrediction(aas_clientmove_t *move, int entnum, const vec3_t origin, int presencetype,
int onground, const vec3_t velocity, const vec3_t cmdmove, int cmdframes,
int maxframes, float frametime, int stopevent, int stopareanum,
const vec3_t mins, const vec3_t maxs, int visualize, int jumper) {
float phys_friction, phys_stopspeed, phys_gravity, phys_waterfriction;
float phys_watergravity;
float phys_walkaccelerate, phys_airaccelerate, phys_swimaccelerate;
Expand Down
8 changes: 4 additions & 4 deletions deps/botlib/be_aas_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move, int entnum, vec3_t
vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime,
vec3_t mins, vec3_t maxs, int visualize);
// cyr{
int AAS_ClientMovementPrediction(struct aas_clientmove_s *move, int entnum, vec3_t origin, int presencetype,
int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes,
float frametime, int stopevent, int stopareanum, vec3_t mins, vec3_t maxs,
int visualize, int jumper);
int AAS_ClientMovementPrediction(aas_clientmove_t *move, int entnum, const vec3_t origin, int presencetype,
int onground, const vec3_t velocity, const vec3_t cmdmove, int cmdframes,
int maxframes, float frametime, int stopevent, int stopareanum,
const vec3_t mins, const vec3_t maxs, int visualize, int jumper);
// cyr}
// returns true if on the ground at the given origin
int AAS_OnGround(vec3_t origin, int presencetype, int passent);
Expand Down
11 changes: 9 additions & 2 deletions deps/botlib/be_aas_reach.c
Original file line number Diff line number Diff line change
Expand Up @@ -3200,8 +3200,11 @@ static aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int n
VectorCopy(bestend, testpoint);
else
VectorCopy(beststart, testpoint);
testpoint[2] = 0;
testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2];
if (bestfaceplane != NULL)
testpoint[2] =
(bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2];
else
testpoint[2] = 0;
//
if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f)) {
// if the faces are not overlapping then only go down
Expand Down Expand Up @@ -3918,6 +3921,10 @@ static void AAS_SetWeaponJumpAreaFlags(void) {
!strcmp(classname, "weapon_rocketlauncher") || !strcmp(classname, "weapon_lightning") ||
!strcmp(classname, "weapon_plasmagun") || !strcmp(classname, "weapon_railgun") ||
!strcmp(classname, "weapon_bfg") || !strcmp(classname, "item_quad") || !strcmp(classname, "item_regen") ||
!strcmp(classname, "item_invulnerability") || !strcmp(classname, "item_armor_padshield") || !strcmp(classname, "weapon_balloony") ||
!strcmp(classname, "weapon_betty") || !strcmp(classname, "weapon_boaster") ||
!strcmp(classname, "weapon_bubbleg") || !strcmp(classname, "weapon_splasher") ||
!strcmp(classname, "weapon_imperius") || !strcmp(classname, "item_padpower") || !strcmp(classname, "item_revival") ||
!strcmp(classname, "item_invulnerability")) {
if (AAS_VectorForBSPEpairKey(ent, "origin", origin)) {
spawnflags = 0;
Expand Down
39 changes: 25 additions & 14 deletions deps/botlib/be_ai_chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,22 +629,25 @@ bot_synonymlist_t *BotLoadSynonyms(const char *filename) {
numsynonyms = 0;
lastsynonym = NULL;
while (1) {
size_t len;
if (!PC_ExpectTokenString(source, "(") || !PC_ExpectTokenType(source, TT_STRING, 0, &token)) {
FreeSource(source);
return NULL;
} // end if
StripDoubleQuotes(token.string);
if (strlen(token.string) <= 0) {
SourceError(source, "empty string", token.string);
len = (int)strlen(token.string);
if (len == 0) {
SourceError(source, "empty string");
FreeSource(source);
return NULL;
} // end if
size += sizeof(bot_synonym_t) + strlen(token.string) + 1;
if (pass) {
len = PAD(len + 1, sizeof(long));
size += sizeof(bot_synonym_t) + len;
if (pass && ptr) {
synonym = (bot_synonym_t *)ptr;
ptr += sizeof(bot_synonym_t);
synonym->string = ptr;
ptr += strlen(token.string) + 1;
ptr += len;
strcpy(synonym->string, token.string);
//
if (lastsynonym)
Expand Down Expand Up @@ -917,17 +920,20 @@ bot_randomlist_t *BotLoadRandomStrings(const char *filename) {
lastrandom = NULL; // last
//
while (PC_ReadToken(source, &token)) {
size_t len;
if (token.type != TT_NAME) {
SourceError(source, "unknown random %s", token.string);
FreeSource(source);
return NULL;
} // end if
size += sizeof(bot_randomlist_t) + strlen(token.string) + 1;
if (pass) {
len = strlen(token.string) + 1;
len = PAD(len, sizeof(long));
size += sizeof(bot_randomlist_t) + len;
if (pass && ptr) {
random = (bot_randomlist_t *)ptr;
ptr += sizeof(bot_randomlist_t);
random->string = ptr;
ptr += strlen(token.string) + 1;
ptr += len;
strcpy(random->string, token.string);
random->firstrandomstring = NULL;
random->numstrings = 0;
Expand All @@ -947,12 +953,14 @@ bot_randomlist_t *BotLoadRandomStrings(const char *filename) {
FreeSource(source);
return NULL;
} // end if
size += sizeof(bot_randomstring_t) + strlen(chatmessagestring) + 1;
if (pass) {
len = strlen(chatmessagestring) + 1;
len = PAD(len, sizeof(long));
size += sizeof(bot_randomstring_t) + len;
if (pass && ptr) {
randomstring = (bot_randomstring_t *)ptr;
ptr += sizeof(bot_randomstring_t);
randomstring->string = ptr;
ptr += strlen(chatmessagestring) + 1;
ptr += len;
strcpy(randomstring->string, chatmessagestring);
//
random->numstrings++;
Expand Down Expand Up @@ -1950,11 +1958,14 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) {
size += sizeof(bot_chattype_t);
// read the chat messages
while (!PC_CheckTokenString(source, "}")) {
size_t len;
if (!BotLoadChatMessage(source, chatmessagestring)) {
FreeSource(source);
return NULL;
} // end if
if (pass) {
len = strlen(chatmessagestring) + 1;
len = PAD(len, sizeof(long));
if (pass && ptr) {
chatmessage = (bot_chatmessage_t *)ptr;
chatmessage->time = -2 * CHATMESSAGE_RECENTTIME;
// put the chat message in the list
Expand All @@ -1964,11 +1975,11 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) {
ptr += sizeof(bot_chatmessage_t);
chatmessage->chatmessage = ptr;
strcpy(chatmessage->chatmessage, chatmessagestring);
ptr += strlen(chatmessagestring) + 1;
ptr += len;
// the number of chat messages increased
chattype->numchatmessages++;
} // end if
size += sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1;
size += sizeof(bot_chatmessage_t) + len;
} // end if
} // end while
} // end if
Expand Down
3 changes: 1 addition & 2 deletions deps/botlib/be_ai_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,6 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
ms->lastreachnum = lastreachnum;
ms->lastareanum = areas[i];
// botimport.Print(PRT_MESSAGE, "found jumppad reachability hard!!\n");
break;
} // end if
} // end for
if (lastreachnum)
Expand Down Expand Up @@ -3558,7 +3557,7 @@ void BotResetLastAvoidReach(int movestate) {
} // end for
if (latesttime) {
ms->avoidreachtimes[latest] = 0;
if (ms->avoidreachtries[i] > 0)
if (ms->avoidreachtries[latest] > 0)
ms->avoidreachtries[latest]--;
} // end if
} // end of the function BotResetLastAvoidReach
Expand Down
5 changes: 3 additions & 2 deletions deps/botlib/l_libvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ float LibVarStringValue(const char *string) {
libvar_t *LibVarAlloc(const char *var_name) {
libvar_t *v;

v = (libvar_t *)GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);
v = (libvar_t *)GetMemory(sizeof(libvar_t));
Com_Memset(v, 0, sizeof(libvar_t));
v->name = (char *)v + sizeof(libvar_t);
v->name = (char *)GetMemory(strlen(var_name) + 1);
strcpy(v->name, var_name);
// add the variable in the list
v->next = libvarlist;
Expand All @@ -94,6 +94,7 @@ libvar_t *LibVarAlloc(const char *var_name) {
void LibVarDeAlloc(libvar_t *v) {
if (v->string)
FreeMemory(v->string);
FreeMemory(v->name);
FreeMemory(v);
} // end of the function LibVarDeAlloc
//===========================================================================
Expand Down
13 changes: 7 additions & 6 deletions deps/botlib/l_precomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ static void PC_FreeDefine(define_t *define) {
PC_FreeToken(t);
} // end for
// free the define
FreeMemory(define->name);
FreeMemory(define);
} // end of the function PC_FreeDefine
//============================================================================
Expand All @@ -646,9 +647,9 @@ void PC_AddBuiltinDefines(source_t *source) {
{NULL, 0}};

for (i = 0; builtin[i].string; i++) {
define = (define_t *)GetMemory(sizeof(define_t) + strlen(builtin[i].string) + 1);
define = (define_t *)GetMemory(sizeof(define_t));
Com_Memset(define, 0, sizeof(define_t));
define->name = (char *)define + sizeof(define_t);
define->name = (char *)GetMemory(strlen(builtin[i].string) + 1);
strcpy(define->name, builtin[i].string);
define->flags |= DEFINE_FIXED;
define->builtin = builtin[i].builtin;
Expand Down Expand Up @@ -1130,9 +1131,9 @@ static int PC_Directive_define(source_t *source) {
#endif // DEFINEHASHING
} // end if
// allocate define
define = (define_t *)GetMemory(sizeof(define_t) + strlen(token.string) + 1);
define = (define_t *)GetMemory(sizeof(define_t));
Com_Memset(define, 0, sizeof(define_t));
define->name = (char *)define + sizeof(define_t);
define->name = (char *)GetMemory(strlen(token.string) + 1);
strcpy(define->name, token.string);
// add the define to the source
#if DEFINEHASHING
Expand Down Expand Up @@ -1353,9 +1354,9 @@ define_t *PC_CopyDefine(source_t *source, define_t *define) {
define_t *newdefine;
token_t *token, *newtoken, *lasttoken;

newdefine = (define_t *)GetMemory(sizeof(define_t) + strlen(define->name) + 1);
newdefine = (define_t *)GetMemory(sizeof(define_t));
// copy the define name
newdefine->name = (char *)newdefine + sizeof(define_t);
newdefine->name = (char *)GetMemory(strlen(define->name) + 1);
strcpy(newdefine->name, define->name);
newdefine->flags = define->flags;
newdefine->builtin = define->builtin;
Expand Down