Пример #1
0
void AvHGamerules::DisplayVersioning()
{
	struct MemoryStruct theChunk;
	CURLcode theCode = PopulateChunkFromURL(BuildVersionURL(), theChunk);

	// Now parse data and add users for each mask
	if((theCode == CURLE_OK) && theChunk.memory)
	{
		string theString(theChunk.memory, theChunk.size);

		string theDelimiters("\r\n");
		StringVector theLines;
		Tokenizer::split(theString, theDelimiters, theLines);

		if(theLines.size() > 0)
		{
			string theCurrentVersion(theLines[0]);
			string theCurrentGameVersion = AvHSUGetGameVersionString();

			char theMessage[1024];
			if(theCurrentGameVersion != theCurrentVersion)
			{
				sprintf(theMessage, "\tServer out of date.  NS version %s is now available!\n", theCurrentVersion.c_str());
				ALERT(at_console, theMessage);
			}
			else
			{
				sprintf(theMessage, "\tServer version is up to date.\n");
				ALERT(at_console, theMessage);
			}
		}
	}
}
Пример #2
0
// Accepts input in the form of:
//  #/#/#/#/nodename/msgID
bool PieNodeList::AddNode(const string& inNodeString, Font* inFont, const Color& inBGColor, const Color& inFGColor, const string& inDefaultImage)
{
    bool theSuccess = false;

    // Parse inNodeString to get node offsets and node name 
    StringVector theTokens;
    string theDelimiters("/");
    Tokenizer::split(inNodeString, theDelimiters, theTokens);

    if(theTokens.size() > 1)
    {
        // Grab directional indicies
        typedef vector<int> DirectionalListType;
        DirectionalListType theDirectionalList;
        
        // For each direction until the last, get the sub node (skip the last two nodes, should be the node name and msg id)
        for(StringVector::iterator theStringIter = theTokens.begin(); ((theStringIter != theTokens.end()) && (theStringIter + 2 != theTokens.end())) ; theStringIter++)
        {
            string theCurrentToken = *theStringIter;
            int theCurrentOffset;
            if(sscanf(theCurrentToken.c_str(), "%d", &theCurrentOffset) == 1)
            {
                theDirectionalList.push_back(theCurrentOffset);
            }
        }
        
        // Grab node name (second to last in the list)
        string theNodeName = *(theTokens.end() - 2);

        // Grab the message id (last in list)
        string theCurrentToken = *(theTokens.end() - 1);
        int theMessageID;
        if(sscanf(theCurrentToken.c_str(), "%d", &theMessageID) != 1)
        {
        }

        // Build the new node
        PieNode* theCurrentNode = this->mRoot;
        ASSERT(theCurrentNode);

        for(DirectionalListType::iterator theIter = theDirectionalList.begin(); ((theIter != theDirectionalList.end()) && (theIter + 1 != theDirectionalList.end()) && (theCurrentNode != NULL)); theIter++)
        {
            theCurrentNode = theCurrentNode->GetNodeAtAngularOffset(*theIter);
        }

        if(theCurrentNode != NULL)
        {
            int theLastOffset = *(theDirectionalList.end() - 1);

            // At this last node, add the new node with the last index
            PieNode* theNewNode = new PieNode(theNodeName, theMessageID);

            if(inFont)
            {
                theNewNode->setFont(inFont);
            }

			theNewNode->setFgColor(inFGColor);
			theNewNode->setBgColor(inBGColor);
			theNewNode->setAsMouseCapture(false);
			theNewNode->SetDefaultImage(inDefaultImage);

            // Set size to be the default size for the rest of the nodes
            //int theNodeListSizeX, theNodeListSizeY;
            //this->mRoot->getSize(theNodeListSizeX, theNodeListSizeY);
            //theNewNode->setSize(theNodeListSizeX, theNodeListSizeY);
            
            theCurrentNode->AttachNode(theNewNode, theLastOffset, this->mNodeXDistance, this->mNodeYDistance);

            // Set x/y as it's current x/y plus the node "before" it in the pie hierarchy
            int thePreviousMenuX, thePreviousMenuY;
            theCurrentNode->getPos(thePreviousMenuX, thePreviousMenuY);

            int theNewNodeRelX, theNewNodeRelY;
            theNewNode->getPos(theNewNodeRelX, theNewNodeRelY);
            theNewNode->setPos(thePreviousMenuX + theNewNodeRelX, thePreviousMenuY + theNewNodeRelY);

			// TODO: Just added this.
			theNewNode->setSize(this->mNodeXDistance*ScreenWidth(), this->mNodeYDistance*ScreenHeight());

            // Set new node's parent as root node's parent
            theNewNode->setParent(this->mRoot->getParent());

            theSuccess = true;
        }
    }

    return theSuccess;
}
Пример #3
0
void AvHGamerules::InitializeAuthentication()
{
	bool theSuccess = false;

	ALERT(at_console, "\tReading authentication data...");

    struct MemoryStruct theChunk;
	CURLcode theCode = PopulateChunkFromURL(BuildAuthenticationURL(), theChunk);
	
	// Now parse data and add users for each mask
	if((theCode == CURLE_OK) && theChunk.memory)
	{
        // Clear existing authentication data, only after lookup succeeds
        gAuthMaskList.clear();

		string theString(theChunk.memory);
		string theDelimiters("\r\n");
		StringVector theLines;
		Tokenizer::split(theString, theDelimiters, theLines);
		
		// Run through each line
		int theNumConstellationMembers = 0;
		for(StringVector::const_iterator theIter = theLines.begin(); theIter != theLines.end(); theIter++)
		{
			char *msg=(char *)(*theIter).c_str();
			// If it's not empty and not a comment
			char theFirstChar = (*theIter)[0];
			if((theFirstChar != '/') && (theFirstChar != '#'))
			{
				// Split up tag and number
				StringVector theTokens;
				if(Tokenizer::split(*theIter, " ", theTokens) == 3)
				{
					// Translate tag to auth mask
					string theTag = theTokens[0];
					string theWONID = theTokens[1];
					string theSteamID = theTokens[2];

                    // Upper-case prefix
                    UppercaseString(theSteamID);

                    // Make sure it starts with "STEAM_X:Y"
					if(strncmp(theSteamID.c_str(), kSteamIDPrefix, strlen(kSteamIDPrefix)))
                    {
                        string theNewSteamID = kSteamIDPrefix + theSteamID;
                        theSteamID = theNewSteamID;
                    }

					// Add auth status
					AvHPlayerAuthentication theMask = PLAYERAUTH_NONE;
					if(TagToAuthMask(theTag, theMask))
					{
						// Count Constellation members fyi
						if(theMask & PLAYERAUTH_CONTRIBUTOR)
						{
							theNumConstellationMembers++;
						}

						if((theWONID != "") || (theSteamID != ""))
						{
#ifdef DEBUG
							char theMessage[512];
							sprintf(theMessage, "	Adding auth mask: %s %s %s\n", theTag.c_str(), theWONID.c_str(), theSteamID.c_str());
							ALERT(at_logged, theMessage);
#endif
							
							this->AddAuthStatus(theMask, theWONID, theSteamID);
							theSuccess = true;
						}
					}
				}
			}
		}

		// Breakpoint to see how many Constellation members there are (don't even think of printing or logging)
		int a = 0;
	}
    else
    {
        int a = 0;
    }

	// Now build server op list
	this->mServerOpList.clear();
		
	// Parse contents server op variable
	string theServerOpsString(avh_serverops.string);
	
	// Tokenize string
	StringVector theServerOpsStrings;
	Tokenizer::split(theServerOpsString, ";", theServerOpsStrings);
	
	// For each in list, add as an int to our list
	for(StringVector::const_iterator theIter = theServerOpsStrings.begin(); theIter != theServerOpsStrings.end(); theIter++)
	{
		// Add whatever the put in this line as both the WONID and SteamID
		string theCurrentAuthID = *theIter;
		this->mServerOpList.push_back( make_pair(theCurrentAuthID, theCurrentAuthID));
	}
	
	if(theSuccess)
	{
		ALERT(at_console, "success.\n");
	}
	else
	{
		ALERT(at_console, "failure.\n");
	}
	gTimeLastUpdatedUplink = AvHSUTimeGetTime();
}