Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int command_index = 0; command_index < command_count; command_index++)
- {
- char* command = g_commands[command_index];
- int command_len = (int)strlen(command);
- assert(command_len > 0);
- int score = 0;
- int start = 0;
- int highest_streak = 0;
- int streak = 0;
- for(int input_char_index = 0; input_char_index < input_len; input_char_index++)
- {
- char input_c = console->input_str.text[input_char_index];
- for(int command_char_index = start; command_char_index < command_len; command_char_index++)
- {
- char command_c = command[command_char_index];
- if(command_c == input_c)
- {
- start = command_char_index + 1;
- streak += 1;
- highest_streak = max(streak, highest_streak);
- score += 1;
- break;
- }
- else
- {
- streak = 0;
- }
- }
- }
- score += highest_streak;
- s_auto_complete_command acc = zero;
- acc.score = score;
- acc.index = command_index;
- accs[command_index] = acc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement