Ejemplo n.º 1
0
int CSaveTeam::load(int Team)
{
	if(Team <= 0 || Team >= MAX_CLIENTS)
		return 1;

	CGameTeams* Teams = &(((CGameControllerDDRace*)m_pController)->m_Teams);

	Teams->ChangeTeamState(Team, m_TeamState);
	Teams->SetTeamLock(Team, m_TeamLocked);

	CCharacter* pchr;

	for (int i = 0; i<m_MembersCount; i++)
	{
		int ID = MatchPlayer(SavedTees[i].GetName());
		if(ID == -1) // first check if team can be loaded / do not load half teams
		{
			return i+10; // +10 to let space for other return-values
		}
		else if (m_pController->GameServer()->m_apPlayers[ID] && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter() && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter()->m_DDRaceState)
		{
			return i+100; // +100 to let space for other return-values
		}
	}

	for (int i = 0; i<m_MembersCount; i++)
	{
		pchr = MatchCharacter(SavedTees[i].GetName(), i);
		if(pchr)
		{
			SavedTees[i].load(pchr, Team);
		}
	}

	if(m_pController->GameServer()->Collision()->m_NumSwitchers)
		for(int i=1; i < m_pController->GameServer()->Collision()->m_NumSwitchers+1; i++)
		{
			m_pController->GameServer()->Collision()->m_pSwitchers[i].m_Status[Team] = m_Switchers[i].m_Status;
			if(m_Switchers[i].m_EndTime)
				m_pController->GameServer()->Collision()->m_pSwitchers[i].m_EndTick[Team] = m_pController->Server()->Tick() - m_Switchers[i].m_EndTime;
			m_pController->GameServer()->Collision()->m_pSwitchers[i].m_Type[Team] = m_Switchers[i].m_Type;
		}
	return 0;
}
Ejemplo n.º 2
0
/**
 * @brief Matches an OSC address pattern expression starting with a star with
 * the next character(s) in the target OSC address.
 *
 * The OSC address pattern must start with a ' *' character.  A ' *' character
 * will be matched to any sequence of zero or more characters in the OSC address
 * up to the next '/' character or to the end of the OSC address.  For example,
 * the OSC address pattern "/colour/b *" would match the OSC addresses
 * "/colour/blue", "/colour/black" and "/colour/brown".
 *
 * The oscAddressPattern and oscAddress pointers are advanced to the character
 * proceeding the matched sequence. This function calls MatchCharacter and so
 * becomes recursive if the expression contains multiple stars.
 *
 * This is an internal function and cannot be called by the user application.
 *
 * @param oscAddressPattern Pointer to first character of OSC address pattern.
 * @param oscAddress Pointer to first character of target OSC address.
 * @param isPartial Flag indicating if a partial match is acceptable.
 * @return true if OSC address pattern and target OSC address match.
 */
static bool MatchStar(const char * * const oscAddressPattern, const char * * const oscAddress, const bool isPartial) {

    // Advance OSC address pattern pointer to character proceeding star(s)
    while (**oscAddressPattern == '*') {
        (*oscAddressPattern)++;
    }

    // Advance OSC address pattern pointer to end of part if star is last character
    if ((**oscAddressPattern == '/') || (**oscAddressPattern == '\0')) {
        while ((**oscAddress != '/') && (**oscAddress != '\0')) {
            (*oscAddress)++;
        }
        return true;
    }

    // Attempt to match remainder of expression for each possible star match
    do {
        const char * oscAddressPatternCache = *oscAddressPattern; // cache character oscAddress proceeding star

        // Advance OSC address pattern to next match of character proceeding star
        while (MatchCharacter(oscAddressPattern, oscAddress, isPartial) == false) {
            (*oscAddress)++;
            if ((**oscAddress == '/') || (**oscAddress == '\0')) {
                if ((isPartial == true) && (**oscAddress == '\0')) {
                    return true;
                }
                return false; // fail: OSC address pattern part ended before match
            }
        }
        const char * oscAddressCache = (*oscAddress); // cache character oscAddress proceeding current star match

        // Attempt to match remainder of expression
        if (MatchExpression(oscAddressPattern, oscAddress, isPartial) == true) { // potentially recursive
            return true;
        } else {
            *oscAddressPattern = oscAddressPatternCache;
            *oscAddress = oscAddressCache;
        }
    } while (true);
}
Ejemplo n.º 3
0
/**
 * @brief Matches an OSC address pattern expression with a target OSC address.
 *
 * The OSC address pattern expression may contain any combination of special
 * characters: '?', ' *', '[]', or '{}'.
 *
 * This is an internal function and cannot be called by the user application.
 *
 * @param oscAddressPattern Pointer to first character of OSC address pattern.
 * @param oscAddress Pointer to first character of target OSC address.
 * @param isPartial Flag indicating if a partial match is acceptable.
 * @return true if OSC address pattern and target OSC address match.
 */
static bool MatchExpression(const char * * const oscAddressPattern, const char * * const oscAddress, const bool isPartial) {
    while (**oscAddressPattern != '\0') {
        if (**oscAddress == '\0') {
            if (isPartial == true) {
                return true;
            }
        }
        if (**oscAddressPattern == '*') {
            if (MatchStar(oscAddressPattern, oscAddress, isPartial) == false) {
                return false; // fail: unable to match star sequence
            }
        } else {
            if (MatchCharacter(oscAddressPattern, oscAddress, isPartial) == false) {
                return false; // fail: unable to match single character, bracketed list or curly braced list
            }
        }
    }
    if (**oscAddress != '\0') {
        return false; // fail: OSC address pattern too long
    }
    return true;
}