Skip to content

Commit

Permalink
Reformat: xrGame
Browse files Browse the repository at this point in the history
  • Loading branch information
invokr committed Jan 15, 2017
1 parent 6cf7972 commit ed510c6
Show file tree
Hide file tree
Showing 2,575 changed files with 252,613 additions and 267,866 deletions.
128 changes: 61 additions & 67 deletions src/xrGame/AI_PhraseDialogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,97 @@
//
///////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AI_PhraseDialogManager.h"
#include "PhraseDialog.h"
#include "inventoryowner.h"
#include "character_info.h"
#include "gameobject.h"
#include "inventoryowner.h"
#include "relation_registry.h"
#include "stdafx.h"

CAI_PhraseDialogManager::CAI_PhraseDialogManager (void)
CAI_PhraseDialogManager::CAI_PhraseDialogManager(void)
{
m_sStartDialog = m_sDefaultStartDialog = NULL;
m_sStartDialog = m_sDefaultStartDialog = NULL;
}

CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void)
{}
CAI_PhraseDialogManager::~CAI_PhraseDialogManager(void)
{
}

//PhraseDialogManager
void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
// PhraseDialogManager
void CAI_PhraseDialogManager::ReceivePhrase(DIALOG_SHARED_PTR& phrase_dialog)
{
AnswerPhrase(phrase_dialog);
CPhraseDialogManager::ReceivePhrase(phrase_dialog);
AnswerPhrase(phrase_dialog);
CPhraseDialogManager::ReceivePhrase(phrase_dialog);
}
#include "uigamesp.h"
#include "Level.h"
#include "ui/UItalkWnd.h"
#include "uigamesp.h"

void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
void CAI_PhraseDialogManager::AnswerPhrase(DIALOG_SHARED_PTR& phrase_dialog)
{
CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this);
THROW (pInvOwner);
CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this));
THROW (pOthersGO);
CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO);
THROW (pOthersIO);

if(!phrase_dialog->IsFinished())
{
CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner);

xr_vector<int> phrases;
CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL;
//åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó
//ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ)
int phrase_num = phrase_dialog->PhraseList().size()-1;
for(u32 i=0; i<phrase_dialog->PhraseList().size(); ++i)
{
phrase_goodwill = phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel();
if(attitude >= phrase_goodwill)
{
phrase_num = i;
break;
}
}

for(u32 i=0; i<phrase_dialog->PhraseList().size(); i++)
{
if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel())
phrases.push_back(i);
}

phrase_num = phrases[Random.randI(0, phrases.size())];

shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID();

CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI());
pGameSP->TalkMenu->AddAnswer (phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name());

CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id);
}
CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this);
THROW(pInvOwner);
CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this));
THROW(pOthersGO);
CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO);
THROW(pOthersIO);

if (!phrase_dialog->IsFinished()) {
CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner);

xr_vector<int> phrases;
CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL;
//åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó
//ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ)
int phrase_num = phrase_dialog->PhraseList().size() - 1;
for (u32 i = 0; i < phrase_dialog->PhraseList().size(); ++i)
{
phrase_goodwill = phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel();
if (attitude >= phrase_goodwill) {
phrase_num = i;
break;
}
}

for (u32 i = 0; i < phrase_dialog->PhraseList().size(); i++)
{
if (phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel()) phrases.push_back(i);
}

phrase_num = phrases[Random.randI(0, phrases.size())];

shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID();

CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI());
pGameSP->TalkMenu->AddAnswer(phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name());

CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id);
}
}



void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog)
{
m_sStartDialog = phrase_dialog;
m_sStartDialog = phrase_dialog;
}

void CAI_PhraseDialogManager::SetDefaultStartDialog(shared_str phrase_dialog)
{
m_sDefaultStartDialog = phrase_dialog;
m_sDefaultStartDialog = phrase_dialog;
}

void CAI_PhraseDialogManager::RestoreDefaultStartDialog()
{
m_sStartDialog = m_sDefaultStartDialog;
m_sStartDialog = m_sDefaultStartDialog;
}

void CAI_PhraseDialogManager::UpdateAvailableDialogs(CPhraseDialogManager* partner)
{
m_AvailableDialogs.clear();
m_CheckedDialogs.clear();

void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner)
{
m_AvailableDialogs.clear();
m_CheckedDialogs.clear();

if(*m_sStartDialog)
inherited::AddAvailableDialog(*m_sStartDialog, partner);
inherited::AddAvailableDialog("hello_dialog", partner);
if (*m_sStartDialog) inherited::AddAvailableDialog(*m_sStartDialog, partner);
inherited::AddAvailableDialog("hello_dialog", partner);

inherited::UpdateAvailableDialogs(partner);
inherited::UpdateAvailableDialogs(partner);
}
40 changes: 20 additions & 20 deletions src/xrGame/AI_PhraseDialogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@

#include "PhraseDialogManager.h"


class CAI_PhraseDialogManager: public CPhraseDialogManager
class CAI_PhraseDialogManager : public CPhraseDialogManager
{
private:
typedef CPhraseDialogManager inherited;
typedef CPhraseDialogManager inherited;

public:
CAI_PhraseDialogManager ();
virtual ~CAI_PhraseDialogManager ();
CAI_PhraseDialogManager();
virtual ~CAI_PhraseDialogManager();

virtual void ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog);
virtual void UpdateAvailableDialogs (CPhraseDialogManager* partner);
virtual void AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog);
virtual void ReceivePhrase(DIALOG_SHARED_PTR& phrase_dialog);
virtual void UpdateAvailableDialogs(CPhraseDialogManager* partner);
virtual void AnswerPhrase(DIALOG_SHARED_PTR& phrase_dialog);

virtual void SetStartDialog(shared_str phrase_dialog);
virtual void SetDefaultStartDialog(shared_str phrase_dialog);
virtual shared_str GetStartDialog() { return m_sStartDialog; }
virtual void RestoreDefaultStartDialog();

virtual void SetStartDialog (shared_str phrase_dialog);
virtual void SetDefaultStartDialog (shared_str phrase_dialog);
virtual shared_str GetStartDialog () {return m_sStartDialog;}
virtual void RestoreDefaultStartDialog ();
protected:
//äèàëîã, åñëè íå NULL, òî åãî ïåðñîíàæ çàïóñòèò
//ïðè âñòðå÷å ñ àêòåðîì
shared_str m_sStartDialog;
shared_str m_sDefaultStartDialog;

DEFINE_VECTOR(DIALOG_SHARED_PTR, DIALOG_SHARED_VECTOR, DIALOG_SHARED_IT);
//ñïèñîê äèàëîãîâ, íà êîòîðûå íóæíî îòâåòèòü
DIALOG_SHARED_VECTOR m_PendingDialogs;
//äèàëîã, åñëè íå NULL, òî åãî ïåðñîíàæ çàïóñòèò
//ïðè âñòðå÷å ñ àêòåðîì
shared_str m_sStartDialog;
shared_str m_sDefaultStartDialog;

DEFINE_VECTOR(DIALOG_SHARED_PTR, DIALOG_SHARED_VECTOR, DIALOG_SHARED_IT);
//ñïèñîê äèàëîãîâ, íà êîòîðûå íóæíî îòâåòèòü
DIALOG_SHARED_VECTOR m_PendingDialogs;
};
63 changes: 28 additions & 35 deletions src/xrGame/ActivatingCharCollisionDelay.cpp
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
#include "stdafx.h"

#include "activatingcharcollisiondelay.h"
#include "CharacterPhysicsSupport.h"
#include "activatingcharcollisiondelay.h"
#include "phmovementcontrol.h"
#ifdef DEBUG
#ifdef DEBUG
#include "phdebug.h"
#endif
activating_character_delay::activating_character_delay(CCharacterPhysicsSupport *char_support_):
char_support(*char_support_),
activate_time(Device.dwTimeGlobal + delay )
activating_character_delay::activating_character_delay(CCharacterPhysicsSupport* char_support_)
: char_support(*char_support_), activate_time(Device.dwTimeGlobal + delay)
{
VERIFY(char_support_);
VERIFY(char_support.movement());
VERIFY( !char_support.movement()->CharacterExist() );
VERIFY(char_support_);
VERIFY(char_support.movement());
VERIFY(!char_support.movement()->CharacterExist());
}
bool activating_character_delay::active()
{
VERIFY(char_support.movement());
return !char_support.movement()->CharacterExist();
VERIFY(char_support.movement());
return !char_support.movement()->CharacterExist();
}
void activating_character_delay::update()
{
if(!active())
return;
if (!active()) return;

if( Device.dwTimeGlobal < activate_time )
return;
if (Device.dwTimeGlobal < activate_time) return;

if( do_position_correct() )
char_support.CreateCharacter();
if (do_position_correct()) char_support.CreateCharacter();

activate_time = Device.dwTimeGlobal + delay;
activate_time = Device.dwTimeGlobal + delay;
}


bool activating_character_delay::do_position_correct()
{
CPHMovementControl *m = char_support.movement();
VERIFY( m );
IGameObject *obj = m->ParentObject();
#ifdef DEBUG
CEntityAlive* e_alife =smart_cast<CEntityAlive*>(obj);
VERIFY(e_alife);
VERIFY(!e_alife->PPhysicsShell());
VERIFY(e_alife->g_Alive());
CPHMovementControl* m = char_support.movement();
VERIFY(m);

IGameObject* obj = m->ParentObject();
#ifdef DEBUG
CEntityAlive* e_alife = smart_cast<CEntityAlive*>(obj);
VERIFY(e_alife);
VERIFY(!e_alife->PPhysicsShell());
VERIFY(e_alife->g_Alive());
#endif
VERIFY( obj );
Fvector sv_pos = obj->Position();
bool ret = char_support.CollisionCorrectObjPos();
if(!ret)
obj->Position().set(sv_pos);
#if 0
VERIFY(obj);
Fvector sv_pos = obj->Position();
bool ret = char_support.CollisionCorrectObjPos();
if (!ret) obj->Position().set(sv_pos);
#if 0
else
{
DBG_OpenCashedDraw();
Expand All @@ -63,6 +57,5 @@ bool activating_character_delay::do_position_correct()
DBG_ClosedCashedDraw(50000);
}
#endif
return ret;

return ret;
}
19 changes: 10 additions & 9 deletions src/xrGame/ActivatingCharCollisionDelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
#include "Common/Noncopyable.hpp"

class CCharacterPhysicsSupport;
class activating_character_delay:
private Noncopyable
class activating_character_delay : private Noncopyable
{
CCharacterPhysicsSupport &char_support;
u32 activate_time;
static const u32 delay = 3000;
CCharacterPhysicsSupport& char_support;
u32 activate_time;
static const u32 delay = 3000;

public:
activating_character_delay(CCharacterPhysicsSupport *char_support_);
void update();
bool active();
activating_character_delay(CCharacterPhysicsSupport* char_support_);
void update();
bool active();

private:
bool do_position_correct();
bool do_position_correct();
};
Loading

0 comments on commit ed510c6

Please sign in to comment.