Something went wrong. Try again.
Dinky little "engine" for the 3DS, using libctru and citro3d (very WIP)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091#include "preprocessor.h"#include "level_types.h"#include <stdbool.h>#include <stdio.h>#include <string.h>
char* get_model_imports(FILE* lfile) { return NULL;}
ParsedLevel* process_hash_statements(FILE* lfile) { ParsedLevel* pl = create_pl(); int character; char statement[12]; //bool hash_block = true;
// SAFETY: The rest of this function should **NEVER** override this element! This is the only // thing that is preventing an overrun of this segment of memory!! statement[11] = '\0';
while(true) { character = fgetc(lfile);
// If the character is EOF, break from the loop; we've done all that we can! // If the character is not a hash, then we don't care about that line and should skip it if(character == EOF) { break; }else if(character != '#') { // We need to skip this entire line, so we have to read until we find a newline or EOF while(true) { //printf("C: %c", character); if(character == '\n' || character == EOF){ break; } character = fgetc(lfile); } continue; } // Iterate over the first few characters (11 at most). If we find a semicolon or space, then add the string // terminator and break out of the inner loop early so we can see what its value is! for(int i = 0; i < 11; i++) { character = fgetc(lfile); if(character == ';' || character == ' ') { statement[i] = '\0'; break; }
statement[i] = (char)character; } printf("%s\n", statement);
if(!strcmp(statement, "include")){ process_include(lfile, pl); } } return pl;}
const size_t MAX_INCLUDE_SIZE = 64;
char* process_include(FILE* lfile, ParsedLevel* pl) { int c; char mod[MAX_INCLUDE_SIZE];
// SAFETY: The rest of this function should **NEVER** override this element! This is the only // thing that is preventing an overrun of this segment of memory!! mod[63] = '\n'; while(true) { c = fgetc(lfile); if(c == ';' || c == '\n'){ break; }else if(c == '"' || c == ' ' || c == ','){ continue; }
for(int i = 0; i < MAX_INCLUDE_SIZE - 1; i++){ if(c == '"'){ mod[i] = '\0'; break; } mod[i] = c; c = fgetc(lfile); }
add_model(pl, mod); } return NULL;}