Removed the usage of friend declaration. CheckStructure dependencies are
now not read in CheckStructure anymore, instead they are set by the CheckManager depending on the direction of the track. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/reverse_mode@10832 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
45bb8ceb40
commit
ff67a5cf4e
@ -52,6 +52,32 @@ CheckManager::CheckManager(const XMLNode &node, Track *track)
|
||||
else
|
||||
printf("Unknown check structure '%s' - ignored.\n", type.c_str());
|
||||
} // for i<node.getNumNodes
|
||||
|
||||
// Now set all 'successors', i.e. check structures that need to get a
|
||||
// state change when a check structure is triggered. This can't be
|
||||
// done in the CheckStructures easily, since reversing a track changes
|
||||
// the direction of the dependencies.
|
||||
for(unsigned int i=0; i<node.getNumNodes(); i++)
|
||||
{
|
||||
const XMLNode *check_node = node.getNode(i);
|
||||
std::vector<int> check_structures_to_change_state;
|
||||
|
||||
check_node->get("other-ids", &check_structures_to_change_state);
|
||||
// Backwards compatibility to tracks exported with older versions of
|
||||
// the track exporter
|
||||
if(check_structures_to_change_state.size()==0)
|
||||
check_node->get("other-id", &check_structures_to_change_state);
|
||||
std::vector<int>::iterator it;
|
||||
for(it=check_structures_to_change_state.begin();
|
||||
it != check_structures_to_change_state.end(); it++)
|
||||
{
|
||||
if(QuadGraph::get()->isReverse())
|
||||
m_all_checks[*it]->addSuccessor(i);
|
||||
else
|
||||
m_all_checks[i]->addSuccessor(*it);
|
||||
}
|
||||
|
||||
}
|
||||
} // CheckManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -65,33 +91,6 @@ CheckManager::~CheckManager()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** Reverse checks order. */
|
||||
void CheckManager::reverse()
|
||||
{
|
||||
std::map<unsigned int, std::vector<unsigned int> > structures_to_change_state;
|
||||
std::vector<CheckStructure*>::iterator it;
|
||||
for(unsigned int i=0;i<m_all_checks.size(); ++i)
|
||||
{
|
||||
for(std::vector<int>::const_iterator it = m_all_checks[i]->m_check_structures_to_change_state.begin();
|
||||
it != m_all_checks[i]->m_check_structures_to_change_state.end(); ++it)
|
||||
{
|
||||
if(*it>=0)
|
||||
{
|
||||
structures_to_change_state[*it].push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(unsigned int i=0;i<m_all_checks.size(); ++i)
|
||||
{
|
||||
m_all_checks[i]->m_check_structures_to_change_state.clear();
|
||||
m_all_checks[i]->m_check_structures_to_change_state.resize(structures_to_change_state[i].size());
|
||||
copy(structures_to_change_state[i].begin(),structures_to_change_state[i].end(),
|
||||
m_all_checks[i]->m_check_structures_to_change_state.begin());
|
||||
}
|
||||
} // reverse
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** Resets all checks. */
|
||||
void CheckManager::reset(const Track &track)
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
~CheckManager();
|
||||
void update(float dt);
|
||||
void reset(const Track &track);
|
||||
void reverse();
|
||||
|
||||
int getCheckStructureCount() const { return m_all_checks.size(); }
|
||||
|
||||
|
@ -33,6 +33,13 @@ CheckStructure::CheckStructure(CheckManager *check_manager,
|
||||
{
|
||||
m_index = index;
|
||||
m_check_manager = check_manager;
|
||||
m_check_type = CT_NEW_LAP;
|
||||
|
||||
// This structure is actually filled by the check manager (necessary
|
||||
// in order to support track reversing).
|
||||
m_check_structures_to_change_state.clear();
|
||||
m_same_group.clear();
|
||||
|
||||
std::string kind;
|
||||
node.get("kind", &kind);
|
||||
if(kind=="lap")
|
||||
@ -47,14 +54,7 @@ CheckStructure::CheckStructure(CheckManager *check_manager,
|
||||
{
|
||||
printf("Unknown check structure '%s' - ignored.\n", kind.c_str());
|
||||
}
|
||||
m_check_structures_to_change_state.clear();
|
||||
node.get("other-ids", &m_check_structures_to_change_state);
|
||||
// Backwards compatibility to tracks exported with older versions of
|
||||
// the track exporter
|
||||
if(m_check_structures_to_change_state.size()==0)
|
||||
node.get("other-id", &m_check_structures_to_change_state);
|
||||
|
||||
m_same_group.clear();
|
||||
node.get("same-group", &m_same_group);
|
||||
// Make sure that the index of this check structure is included in
|
||||
// the same_group list. While this should be guaranteed by the
|
||||
|
@ -47,7 +47,6 @@ class CheckManager;
|
||||
*/
|
||||
class CheckStructure
|
||||
{
|
||||
friend class CheckManager;
|
||||
public:
|
||||
/** Different types of check structures:
|
||||
* ACTIVATE: Activates another check structure (independent of
|
||||
@ -113,13 +112,20 @@ public:
|
||||
* \param indx Index of the kart, can be used to store kart specific
|
||||
* additional data.
|
||||
*/
|
||||
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx)=0;
|
||||
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
||||
int indx)=0;
|
||||
virtual void trigger(unsigned int kart_index);
|
||||
virtual void reset(const Track &track);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the type of this check structure. */
|
||||
CheckType getType() const { return m_check_type; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds the index of a successor check structure which will get triggered
|
||||
* by this check structure. */
|
||||
void addSuccessor(unsigned int i) {
|
||||
m_check_structures_to_change_state.push_back(i);
|
||||
} // addSuccessor
|
||||
}; // CheckStructure
|
||||
|
||||
#endif
|
||||
|
@ -1316,9 +1316,6 @@ void Track::loadTrackModel(World* parent, bool reverse_track,
|
||||
else if(name=="checks")
|
||||
{
|
||||
m_check_manager = new CheckManager(*node, this);
|
||||
if(reverse_track) {
|
||||
m_check_manager->reverse();
|
||||
}
|
||||
}
|
||||
else if (name=="particle-emitter")
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user