Skip to content

Instantly share code, notes, and snippets.

@nramsbottom
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save nramsbottom/c40e5a590fe718c6ba38 to your computer and use it in GitHub Desktop.

Select an option

Save nramsbottom/c40e5a590fe718c6ba38 to your computer and use it in GitHub Desktop.
/* Albion Gold Boost for DOS */
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <sys/types.h>
int main(int argc, char *argv[]) {
int fd;
char buf[4];
unsigned short gold;
char found;
if (argc < 2) {
printf("agb <filename>\n");
return 1;
}
fd = open(argv[1], O_RDWR);
if (fd == -1) {
printf("error: failed to open file\n");
return 1;
}
found = 0;
while (!eof(fd)) {
read(fd, buf, 4);
if (buf[0] == 'X' && buf[1] == 'L' && buf[2] == 'D' && buf[3] == '0') {
found = 1;
break;
}
}
if (!found) {
printf("error: unable to locate xld record.\n");
close(fd);
return 1;
}
lseek(fd, 245, SEEK_CUR);
lseek(fd, 15, SEEK_CUR);
read(fd, &gold, sizeof(gold));
lseek(fd, -1 * sizeof(gold), SEEK_CUR);
printf("Tom has %d gold. Increasing by 100.\n", gold / 10);
gold += 1000;
write(fd, &gold, sizeof(gold));
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment