Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc/Linux update #117

Merged
merged 4 commits into from
Apr 27, 2021
Merged
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
6 changes: 3 additions & 3 deletions sp/src/game/server/ai_expresserfollowup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static CResponseQueue::CFollowupTargetSpec_t ResolveFollowupTargetToEntity( AICo

ConVar chet_debug_idle( "chet_debug_idle", "0", FCVAR_ARCHIVE, "If set one, many debug prints to help track down the TLK_IDLE issue. Set two for super verbose info" );
// extern ConVar chet_debug_idle;
bool CAI_ExpresserWithFollowup::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
bool CAI_ExpresserWithFollowup::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
{
VPROF("CAI_Expresser::Speak");
if ( IsSpeechGloballySuppressed() )
Expand Down Expand Up @@ -261,7 +261,7 @@ bool CAI_ExpresserWithFollowup::Speak( AIConcept_t &concept, const char *modifie
}
}

SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
SpeechMsg( GetOuter(), "%s (%p) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );

bool spoke = SpeakDispatchResponse( concept, &result, &criteria, filter );
Expand Down Expand Up @@ -297,7 +297,7 @@ static float GetSpeechDurationForResponse( const AI_Response * RESTRICT response
// Purpose: Dispatches the result
// Input : *response -
//-----------------------------------------------------------------------------
bool CAI_ExpresserWithFollowup::SpeakDispatchResponse( AIConcept_t &concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter )
bool CAI_ExpresserWithFollowup::SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter )
{
// This gives the chance for the other bot to respond.
if ( !concept.GetSpeaker().IsValid() )
Expand Down
8 changes: 4 additions & 4 deletions sp/src/game/server/ai_playerally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,11 @@ void CAI_PlayerAlly::PostSpeakDispatchResponse( AIConcept_t concept, AI_Response
{
if ( bSaidHelloToNPC )
{
Warning("Q&A: '%s' said Hello to '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), concept );
Warning("Q&A: '%s' said Hello to '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), (const char*)concept );
}
else
{
Warning("Q&A: '%s' questioned '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), concept );
Warning("Q&A: '%s' questioned '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), (const char*)concept );
}
NDebugOverlay::HorzArrow( GetAbsOrigin(), GetSpeechTarget()->GetAbsOrigin(), 8, 0, 255, 0, 64, true, duration );
}
Expand Down Expand Up @@ -1022,11 +1022,11 @@ void CAI_PlayerAlly::AnswerQuestion( CAI_PlayerAlly *pQuestioner, int iQARandomN
}
}

Assert( selection.pResponse );
SetSpeechTarget( selection.hSpeechTarget );
#ifdef NEW_RESPONSE_SYSTEM
SpeakDispatchResponse( selection.concept.c_str(), &selection.Response );
#else
Assert( selection.pResponse );
SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
#endif

Expand Down Expand Up @@ -1078,11 +1078,11 @@ int CAI_PlayerAlly::SelectNonCombatSpeechSchedule()
AISpeechSelection_t selection;
if ( SelectNonCombatSpeech( &selection ) )
{
Assert( selection.pResponse );
SetSpeechTarget( selection.hSpeechTarget );
#ifdef NEW_RESPONSE_SYSTEM
SetPendingSpeech( selection.concept.c_str(), &selection.Response );
#else
Assert( selection.pResponse );
SetPendingSpeech( selection.concept.c_str(), selection.pResponse );
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion sp/src/game/server/ai_speech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ char *CAI_Expresser::ParseApplyContext( const char *szContext )
{
// If it's really 0, then this is a waste of time
Warning("\"%s\" was detected by applyContext operators as an operable number, but it's not.\n", szValue);
return strdup(szContext);
return szContext;
}

// This is the existing value; will be operated upon and become the final assignment
Expand Down
49 changes: 28 additions & 21 deletions sp/src/game/server/ai_speech_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "ai_speech.h"

#include "game.h"
#include "engine/ienginesound.h"
#include "keyvalues.h"
#include "engine/IEngineSound.h"
#include "KeyValues.h"
#include "ai_basenpc.h"
#include "ai_criteria.h"
#include "AI_Criteria.h"
#include "isaverestore.h"
#include "sceneentity.h"
#include "ai_speechqueue.h"
Expand Down Expand Up @@ -575,7 +575,7 @@ void CAI_Expresser::GatherCriteria( AI_CriteriaSet * RESTRICT outputSet, const A
// Output : AI_Response
//-----------------------------------------------------------------------------
// AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char *modifiers /*= NULL*/ )
bool CAI_Expresser::FindResponse( AI_Response &outResponse, AIConcept_t &concept, AI_CriteriaSet *criteria )
bool CAI_Expresser::FindResponse( AI_Response &outResponse, const AIConcept_t &concept, AI_CriteriaSet *criteria )
{
VPROF("CAI_Expresser::FindResponse");
IResponseSystem *rs = GetOuter()->GetResponseSystem();
Expand Down Expand Up @@ -703,7 +703,7 @@ bool CAI_Expresser::FindResponse( AI_Response &outResponse, AIConcept_t &concept
// NULL -
// Output : bool : true on success, false on fail
//-----------------------------------------------------------------------------
AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, AIConcept_t &concept, AI_CriteriaSet *criteria )
AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, const AIConcept_t &concept, AI_CriteriaSet *criteria )
{
Assert(response);

Expand Down Expand Up @@ -808,7 +808,7 @@ AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, AIConcept_t
// Purpose: Dispatches the result
// Input : *response -
//-----------------------------------------------------------------------------
bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t &concept, AI_Response *result, AI_CriteriaSet *criteria, IRecipientFilter *filter /* = NULL */ )
bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *result, AI_CriteriaSet *criteria, IRecipientFilter *filter /* = NULL */ )
{
char response[ 256 ];
result->GetResponse( response, sizeof( response ) );
Expand Down Expand Up @@ -1068,21 +1068,21 @@ bool CAI_Expresser::FireEntIOFromResponse( char *response, CBaseEntity *pInitiat
char *pszParam;
char *strtokContext;

pszEntname = strtok_s( response, " ", &strtokContext );
pszEntname = V_strtok_s( response, " ", &strtokContext );
if ( !pszEntname )
{
Warning( "Response was entityio but had bad value %s\n", response );
return false;
}

pszInput = strtok_s( NULL, " ", &strtokContext );
pszInput = V_strtok_s( NULL, " ", &strtokContext );
if ( !pszInput )
{
Warning( "Response was entityio but had bad value %s\n", response );
return false;
}

pszParam = strtok_s( NULL, " ", &strtokContext );
pszParam = V_strtok_s( NULL, " ", &strtokContext );

// poke entity io
CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, pszEntname, pInitiator );
Expand Down Expand Up @@ -1231,7 +1231,7 @@ void CAI_Expresser::MarkResponseAsUsed( AI_Response *response )
// Input : concept -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CAI_Expresser::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
{
concept.SetSpeaker(GetOuter());
AI_CriteriaSet criteria;
Expand All @@ -1245,7 +1245,7 @@ bool CAI_Expresser::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CAI_Expresser::Speak( AIConcept_t &concept, AI_CriteriaSet * RESTRICT criteria, char *pszOutResponseChosen , size_t bufsize , IRecipientFilter *filter )
bool CAI_Expresser::Speak( const AIConcept_t &concept, AI_CriteriaSet * RESTRICT criteria, char *pszOutResponseChosen , size_t bufsize , IRecipientFilter *filter )
{
VPROF("CAI_Expresser::Speak");
if ( IsSpeechGloballySuppressed() )
Expand All @@ -1260,7 +1260,7 @@ bool CAI_Expresser::Speak( AIConcept_t &concept, AI_CriteriaSet * RESTRICT crite
return false;
}

SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
SpeechMsg( GetOuter(), "%s (%p) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );

bool spoke = SpeakDispatchResponse( concept, &result, criteria, filter );
Expand Down Expand Up @@ -1447,7 +1447,7 @@ bool CAI_Expresser::CanSpeakAfterMyself()
}

//-------------------------------------
bool CAI_Expresser::CanSpeakConcept( AIConcept_t concept )
bool CAI_Expresser::CanSpeakConcept( const AIConcept_t &concept )
{
// Not in history?
int iter = m_ConceptHistories.Find( concept );
Expand Down Expand Up @@ -1479,14 +1479,14 @@ bool CAI_Expresser::CanSpeakConcept( AIConcept_t concept )

//-------------------------------------

bool CAI_Expresser::SpokeConcept( AIConcept_t concept )
bool CAI_Expresser::SpokeConcept( const AIConcept_t &concept )
{
return GetTimeSpokeConcept( concept ) != -1.f;
}

//-------------------------------------

float CAI_Expresser::GetTimeSpokeConcept( AIConcept_t concept )
float CAI_Expresser::GetTimeSpokeConcept( const AIConcept_t &concept )
{
int iter = m_ConceptHistories.Find( concept );
if ( iter == m_ConceptHistories.InvalidIndex() )
Expand All @@ -1498,7 +1498,7 @@ float CAI_Expresser::GetTimeSpokeConcept( AIConcept_t concept )

//-------------------------------------

void CAI_Expresser::SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback )
void CAI_Expresser::SetSpokeConcept( const AIConcept_t &concept, AI_Response *response, bool bCallback )
{
int idx = m_ConceptHistories.Find( concept );
if ( idx == m_ConceptHistories.InvalidIndex() )
Expand All @@ -1523,7 +1523,7 @@ void CAI_Expresser::SetSpokeConcept( AIConcept_t concept, AI_Response *response,

//-------------------------------------

void CAI_Expresser::ClearSpokeConcept( AIConcept_t concept )
void CAI_Expresser::ClearSpokeConcept( const AIConcept_t &concept )
{
m_ConceptHistories.Remove( concept );
}
Expand Down Expand Up @@ -1560,7 +1560,7 @@ bool CAI_Expresser::IsValidResponse( ResponseType_t type, const char *pszValue )
CAI_TimedSemaphore *CAI_Expresser::GetMySpeechSemaphore( CBaseEntity *pNpc )
{
if ( !pNpc->MyNPCPointer() )
return false;
return NULL;

return (pNpc->MyNPCPointer()->IsPlayerAlly() ? &g_AIFriendliesTalkSemaphore : &g_AIFoesTalkSemaphore );
}
Expand All @@ -1573,16 +1573,23 @@ void CAI_Expresser::SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... )
if ( !DebuggingSpeech() )
return;

va_list arg_ptr;

va_start(arg_ptr, pszFormat);
CFmtStr formatted;
formatted.sprintf_argv(pszFormat, arg_ptr);
va_end(arg_ptr);

if ( pFlex->MyNPCPointer() )
{

DevMsg( pFlex->MyNPCPointer(), CFmtStr( &pszFormat ) );
DevMsg( pFlex->MyNPCPointer(), "%s", formatted.Get() );
}
else
{
CGMsg( 1, CON_GROUP_SPEECH_AI, CFmtStr( &pszFormat ) );
CGMsg( 1, CON_GROUP_SPEECH_AI, "%s", formatted.Get() );
}
UTIL_LogPrintf( (char *) ( (const char *) CFmtStr( &pszFormat ) ) );
UTIL_LogPrintf( "%s", formatted.Get() );
}

//-----------------------------------------------------------------------------
Expand Down
Loading