Пример #1
0
static S32 doRenderMessages(const ClientGame *game, const InputCodeManager *inputCodeManager, HelpItem helpItem, F32 yPos, const Color &color, F32 alpha)
{
   const char * const *messages = helpItems[helpItem].helpMessages;

   S32 lines = 0;
   S32 maxw = 0;
   F32 xPos = DisplayManager::getScreenInfo()->getGameCanvasWidth() / 2.0f;
   S32 yOffset = 0;

   // Final item in messages array will be NULL; loop until we hit that
   for(S32 i = 0; messages[i]; i++)
   {
      TNLAssert(i < MAX_LINES, "Too many lines... better increase MAX_LINES!");

      // Do some token subsititution for dynamic elements such as keybindings
      SymbolString symbolString(messages[i], inputCodeManager, HelpItemContext, FontSize, color, alpha, true);

      symbolString.render(xPos, yPos + yOffset, AlignmentCenter);

      S32 w = symbolString.getWidth();
      maxw = max(maxw, w);

      yOffset += FontSize + FontGap;
      lines++;
   }

   S32 leftPos = (S32)xPos - maxw / 2;
   S32 topPos  = (S32)yPos + yOffset - (lines + 1) * (FontSize + FontGap);
   S32 botPos  = (S32)yPos + yOffset - FontSize + 4;    // 4.... just... because?
   renderMessageDoodads(game, helpItem, leftPos, topPos, botPos, color, alpha);

   return yOffset;
}
Пример #2
0
void Player::getSymbol() {
    symbol_ = symbolString(*character_);
    char c = character_[1];
    bool isSpace = (c == ' ');
    isEndOfWord_ = (c == 0 || isSpace);
    if (isSpace)
        ++character_;
}
Пример #3
0
 /**
  * Get the display text of the symbol and offset of the specified address.
  * 
  * @param process                   Process handle
  * @param address                   Address to find
  * @param symbolInfo                Caller's pre-built SYMBOL_INFO struct (for efficiency)
  * @param returnedSymbolAndOffset   Returned symbol and offset
  */
 static void getsymbolAndOffset( HANDLE process,
                                 DWORD64 address,
                                 SYMBOL_INFO* symbolInfo,
                                 std::string* returnedSymbolAndOffset ) {
     DWORD64 displacement64;
     BOOL ret = SymFromAddr( process, address, &displacement64, symbolInfo );
     if ( FALSE == ret ) {
         *returnedSymbolAndOffset = "???";
         return;
     }
     std::string symbolString( symbolInfo->Name );
     static const size_t bufferSize = 32;
     boost::scoped_array<char> symbolOffset( new char[bufferSize] );
     _snprintf( symbolOffset.get(), bufferSize, "+0x%x", displacement64 );
     symbolString += symbolOffset.get();
     returnedSymbolAndOffset->swap( symbolString );
 }
Пример #4
0
void Learner::start(Teacher &teacher) {
	
	askAlphabet(teacher);
	
	// Initialize S and E to {epsilon}.
	init();
	
	// Ask membership query for epsilon
	makeMembershipQuery(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, teacher);

	// Ask membership queries for each a in A
	for (char symbol : alphabet.getSymbols()) {
	
		if (symbol == EMPTY_CHAR) {
			makeMembershipQuery(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, teacher);
		}
		else {
			String symbolString(1, symbol);
			makeMembershipQuery(symbolString, EMPTY_STRING, symbolString, teacher);
		}
	}
	
	// Construct the initial observation table (S, E, T)
	std::cout << observeTable.toStringTable() << std::endl;
	
	bool conjectureIsIncorrect = true;
	
	while (conjectureIsIncorrect) {
		
		while (!observeTable.isClosed(alphabet) || !observeTable.isConsistent(alphabet)) {
			
			if (!observeTable.isConsistent(alphabet)) {
				std::cout << "Table is not consistent..." << std::endl;
				resolveNotConsistent(teacher);
			}
			if (!observeTable.isClosed(alphabet)) {
				std::cout << "Table is not closed..." << std::endl;
				resolveNotClosed(teacher);
			}
		}
		std::cout << observeTable.toStringSets() << std::endl;
		std::cout << observeTable.toStringTable() << std::endl;
		
		outputDfa();
		
		// The learner was correct
		if (makeConjecture(teacher)) {
			conjectureIsIncorrect = false;
		} // The learner was incorrect
		else {
			printCounterExamplePrompt();
			String t = teacher.getCounterExample();
			
			// Add t and all its prefixes to S
			for (int length = t.length(); length > 0; length--) {
				observeTable.addStringToS(t.substr(0, length));
			}
			
			// Extend T to (S u S . A) . E using membership queries
			extendT(teacher);
			
		}
		
		std::cout << observeTable.toStringSets() << std::endl;
	}
	
	outputDfa();
}