Created
August 17, 2024 22:23
-
-
Save rtldg/2a27e8a744d0927f1202e0f9da5a7010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void OnPluginStart() | |
| { | |
| char output[0xFFFF], data[0xFFFF]; | |
| int outputpos; | |
| int pointer; | |
| char code[] = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."; | |
| for (int i; code[i]; i++) { | |
| switch (code[i]) { | |
| case '>': pointer++ | |
| case '<': pointer--; | |
| case '+': data[pointer]++; | |
| case '-': data[pointer]--; | |
| case '.': output[outputpos++] = data[pointer]; | |
| case ',': SetFailState("Receiving input to brainfuck is not implemented"); | |
| case '[': | |
| if (!data[pointer]) | |
| { | |
| int depth, c; | |
| while ((c = code[++i])) | |
| { | |
| if (c == '[') | |
| depth++; | |
| else if (c == ']' && depth != 0) | |
| depth--; | |
| else if (c == ']' && depth == 0) | |
| break; | |
| } | |
| } | |
| case ']': | |
| if (data[pointer]) | |
| { | |
| int depth, c; | |
| while ((c = code[--i])) | |
| { | |
| if (c == ']') | |
| depth++; | |
| else if (c == '[' && depth != 0) | |
| depth--; | |
| else if (c == '[' && depth == 0) | |
| break; | |
| } | |
| } | |
| } | |
| } | |
| PrintToServer("%s", output); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment