diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2012-08-30 16:16:25 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2012-08-30 17:03:31 -0700 |
commit | 41974ae5265fbc23a06f276f9e008d5dad020e0b (patch) | |
tree | 9d595215172e87e2d83b74f7bf3430b3040e780e /src/tool/skillfrob.cpp | |
parent | 21742909143df9159b2401c3e2a39cc0b2bad620 (diff) | |
download | tmwa-41974ae5265fbc23a06f276f9e008d5dad020e0b.tar.gz tmwa-41974ae5265fbc23a06f276f9e008d5dad020e0b.tar.bz2 tmwa-41974ae5265fbc23a06f276f9e008d5dad020e0b.tar.xz tmwa-41974ae5265fbc23a06f276f9e008d5dad020e0b.zip |
Rename files for C++ conversion. Does not compile.
After updating, you can remove these files, as shown in 'git status':
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/map/magic-interpreter-lexer.c
src/map/magic-interpreter-parser.c
src/map/magic-interpreter-parser.h
Diffstat (limited to 'src/tool/skillfrob.cpp')
-rw-r--r-- | src/tool/skillfrob.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/tool/skillfrob.cpp b/src/tool/skillfrob.cpp new file mode 100644 index 0000000..901f765 --- /dev/null +++ b/src/tool/skillfrob.cpp @@ -0,0 +1,80 @@ +// Compile with +// gcc -m32 -Wall -Wno-pointer-sign -fno-strict-aliasing -I src/char -I src/common src/tool/skillfrob.c -o skillfrob src/common/timer.o src/common/malloc.o src/common/socket.o src/common/lock.o src/common/db.o src/char/int_storage.o src/char/inter.o src/char/int_party.o src/char/int_guild.o + +#include <stdio.h> +#include <stdlib.h> +#include "../common/mmo.hpp" +#include "../char/char.cpp" + +unsigned char skills[MAX_SKILL]; + +void transform_char (struct mmo_charstatus *p) +{ + int i; + + for (i = 0; i < MAX_SKILL; i++) + { + if (skills[(*p).skill[i].id]) + { + (*p).skill[i].lv = 0; + (*p).skill[i].flags = 0; + } + } +} + +int mmo_char_convert () +{ + char line[965536]; + int ret; + struct mmo_charstatus char_dat; + FILE *ifp, *ofp; + + ifp = stdin; + ofp = stdout; + while (fgets (line, 65535, ifp)) + { + memset (&char_dat, 0, sizeof (struct mmo_charstatus)); + ret = mmo_char_fromstr (line, &char_dat); + if (ret) + { + transform_char (&char_dat); + mmo_char_tostr (line, &char_dat); + fprintf (ofp, "%s\n", line); + } + } + fcloseall (); + return 0; +} + +int init (int count, char **translates) +{ + int i, skill; + + memset (skills, 0, sizeof (skills)); + + for (i = 0; i < count; i++) + { + skill = atoi (translates[i]); + if (skill > 0) + { + skills[skill] = 1; + } + } + + return 0; +} + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + printf ("Usage: %s skillid1 skillid2 ...\n", argv[0]); + exit (0); + } + if (init (argc - 1, argv + 1)) + return 1; + + mmo_char_convert (); + + return 0; +} |