Created
April 21, 2014 20:24
-
-
Save Orpheon/11155361 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
| void export_navmesh(Navmesh *mesh, char* name) | |
| { | |
| char filename[strlen(name)+strlen(".navmesh")]; | |
| strcpy(filename, name); | |
| strcat(filename, ".navmesh"); | |
| FILE *f; | |
| f = fopen(filename, "w"); | |
| fwrite((const void*) &(mesh->num_rects), sizeof(int), 1, f); | |
| RectLinkedList *l; | |
| Rect *r; | |
| l = mesh->list; | |
| for (int i=0; i<mesh->num_rects; i++) | |
| { | |
| r = l->rect; | |
| if (i == 75) | |
| { | |
| printf("\n\nPos: x: %i, y: %i", r->topleft.x, r->topleft.y); | |
| printf("\nX: %i", r->topleft.x); | |
| printf("\nY: %i", *(&(r->topleft.x)+1)); | |
| fflush(stdout); | |
| } | |
| // Write everything to file | |
| fwrite((const void*) &(r->topleft.x), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->topleft.y), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->bottomleft.x), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->bottomleft.y), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->topright.x), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->topright.y), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->bottomright.x), sizeof(int), 1, f); | |
| fwrite((const void*) &(r->bottomright.y), sizeof(int), 1, f); | |
| l = l->next; | |
| } | |
| l = mesh->list; | |
| int tmp; | |
| for (int i=0; i<mesh->num_rects; i++) | |
| { | |
| r = l->rect; | |
| fwrite(&(r->num_connections), sizeof(int), 1, f); | |
| for (int j=0; j<r->num_connections; j++) | |
| { | |
| tmp = find_index(mesh, r->connections[j]); | |
| fwrite((const void*) &tmp, sizeof(int), 1, f); | |
| } | |
| l = l->next; | |
| } | |
| fclose(f); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment