Merge in dungeon map changes #1
@@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
const int MAXLENGTH = 0x300;
|
const int MAXLENGTH = 0x300;
|
||||||
@@ -149,10 +150,15 @@ int write_section(struct section section, char data[], char buf[], int loc) {
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf("Usage: %s infile outfile\n", argv[0]);
|
printf("Usage: %s infile outfile [start [length]]\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
off_t seek = 0;
|
||||||
|
if (argc > 3) {
|
||||||
|
seek = strtol(argv[3], NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
FILE *inptr;
|
FILE *inptr;
|
||||||
if ((inptr = fopen(argv[1], "rb")) == NULL) {
|
if ((inptr = fopen(argv[1], "rb")) == NULL) {
|
||||||
printf("%s does not exist.\n", argv[1]);
|
printf("%s does not exist.\n", argv[1]);
|
||||||
@@ -170,10 +176,15 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("Error stating file: %s\n", argv[1]);
|
printf("Error stating file: %s\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
off_t size = buf.st_size;
|
off_t size = buf.st_size - seek;
|
||||||
|
|
||||||
|
if (argc > 4) {
|
||||||
|
size = strtol(argv[4], NULL, 0);
|
||||||
|
}
|
||||||
char inbuf[size];
|
char inbuf[size];
|
||||||
|
|
||||||
|
fseek(inptr, seek, SEEK_SET);
|
||||||
|
|
||||||
if (fread(inbuf, 1, size, inptr) < size) {
|
if (fread(inbuf, 1, size, inptr) < size) {
|
||||||
printf("Error reading file: %s\n", argv[1]);
|
printf("Error reading file: %s\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -181,7 +192,6 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
fclose(inptr);
|
fclose(inptr);
|
||||||
|
|
||||||
|
|
||||||
char outbuf[size * 2];
|
char outbuf[size * 2];
|
||||||
char m0data[MAXLENGTH];
|
char m0data[MAXLENGTH];
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user