summaryrefslogtreecommitdiff
path: root/src/tool
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2009-12-25 05:00:31 -0500
committerJared Adams <jaxad0127@gmail.com>2009-12-26 00:40:11 -0700
commit634aeeb9d58b01f9de6632a014a063ef0c4cf31e (patch)
tree70023dd2bcc12a3f96ec6f118d80e27411920531 /src/tool
parent113fcc4f0a7a0921e94bc415515dd4b393a29d60 (diff)
downloadtmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.gz
tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.bz2
tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.xz
tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.zip
Used the "indent" C formatting program from GNU to do some clean ups
The command options used was: -nbad -bap -sc -bl -blf -bli0 -cli4 -cbi0 -di5 -nbc -bls -ip2 -nut -ts4 -bap -i4 -sob -npsl
Diffstat (limited to 'src/tool')
-rw-r--r--src/tool/adduser.c177
-rw-r--r--src/tool/convert.c528
-rw-r--r--src/tool/itemfrob.c191
-rw-r--r--src/tool/mapfrob.c170
-rw-r--r--src/tool/skillfrob.c100
5 files changed, 612 insertions, 554 deletions
diff --git a/src/tool/adduser.c b/src/tool/adduser.c
index e22e7e9..6ebbdf1 100644
--- a/src/tool/adduser.c
+++ b/src/tool/adduser.c
@@ -12,85 +12,104 @@ char *account_txt = "../save/account.txt";
//-----------------------------------------------------
// Function to suppress control characters in a string.
//-----------------------------------------------------
-int remove_control_chars(unsigned char *str) {
- int i;
- int change = 0;
-
- for(i = 0; str[i]; i++) {
- if (str[i] < 32) {
- str[i] = '_';
- change = 1;
- }
- }
-
- return change;
+int remove_control_chars (unsigned char *str)
+{
+ int i;
+ int change = 0;
+
+ for (i = 0; str[i]; i++)
+ {
+ if (str[i] < 32)
+ {
+ str[i] = '_';
+ change = 1;
+ }
+ }
+
+ return change;
}
-int main(int argc, char *argv[]) {
-
- char username[24];
- char password[24];
- char sex[2];
-
- int next_id, id;
- char line[1024];
-
- // Check to see if account.txt exists.
- printf("Checking if '%s' file exists...\n", account_txt);
- FILE *FPaccin = fopen_(account_txt, "r");
- if (FPaccin == NULL) {
- printf("'%s' file not found!\n", account_txt);
- printf("Run the setup wizard please.\n");
- exit(0);
- }
-
- next_id = 2000000;
- while(fgets(line, sizeof(line)-1, FPaccin)) {
- if (line[0] == '/' && line[1] == '/') { continue; }
- if (sscanf(line, "%d\t%%newid%%\n", &id) == 1) {
- if (next_id < id) {
- next_id = id;
- }
- } else {
- sscanf(line,"%i%[^ ]", &id);
- if (next_id <= id) {
- next_id = id +1;
- }
- }
- }
- close(FPaccin);
- printf("File exists.\n");
-
- printf("Don't create an account if the login-server is online!!!\n");
- printf("If the login-server is online, press ctrl+C now to stop this software.\n");
- printf("\n");
-
- strcpy(username, "");
- while (strlen(username) < 4 || strlen(username) > 23) {
- printf("Enter an username (4-23 characters): ");
- scanf("%s", &username);
- username[23] = 0;
- remove_control_chars(username);
- }
-
- strcpy(password, "");
- while (strlen(password) < 4 || strlen(password) > 23) {
- printf("Enter a password (4-23 characters): ");
- scanf("%s", &password);
- password[23] = 0;
- remove_control_chars(password);
- }
-
- strcpy(sex, "");
- while (strcmp(sex, "F") != 0 && strcmp(sex, "M") != 0) {
- printf("Enter a gender (M for male, F for female): ");
- scanf("%s", &sex);
- }
-
- FILE *FPaccout = fopen_(account_txt, "r+");
- fseek(FPaccout, 0, SEEK_END);
- fprintf(FPaccout, "%i %s %s - %s -\r\n", next_id, username, password, sex);
- close(FPaccout);
-
- printf("Account added.\n");
+int main (int argc, char *argv[])
+{
+
+ char username[24];
+ char password[24];
+ char sex[2];
+
+ int next_id, id;
+ char line[1024];
+
+ // Check to see if account.txt exists.
+ printf ("Checking if '%s' file exists...\n", account_txt);
+ FILE *FPaccin = fopen_ (account_txt, "r");
+ if (FPaccin == NULL)
+ {
+ printf ("'%s' file not found!\n", account_txt);
+ printf ("Run the setup wizard please.\n");
+ exit (0);
+ }
+
+ next_id = 2000000;
+ while (fgets (line, sizeof (line) - 1, FPaccin))
+ {
+ if (line[0] == '/' && line[1] == '/')
+ {
+ continue;
+ }
+ if (sscanf (line, "%d\t%%newid%%\n", &id) == 1)
+ {
+ if (next_id < id)
+ {
+ next_id = id;
+ }
+ }
+ else
+ {
+ sscanf (line, "%i%[^ ]", &id);
+ if (next_id <= id)
+ {
+ next_id = id + 1;
+ }
+ }
+ }
+ close (FPaccin);
+ printf ("File exists.\n");
+
+ printf ("Don't create an account if the login-server is online!!!\n");
+ printf
+ ("If the login-server is online, press ctrl+C now to stop this software.\n");
+ printf ("\n");
+
+ strcpy (username, "");
+ while (strlen (username) < 4 || strlen (username) > 23)
+ {
+ printf ("Enter an username (4-23 characters): ");
+ scanf ("%s", &username);
+ username[23] = 0;
+ remove_control_chars (username);
+ }
+
+ strcpy (password, "");
+ while (strlen (password) < 4 || strlen (password) > 23)
+ {
+ printf ("Enter a password (4-23 characters): ");
+ scanf ("%s", &password);
+ password[23] = 0;
+ remove_control_chars (password);
+ }
+
+ strcpy (sex, "");
+ while (strcmp (sex, "F") != 0 && strcmp (sex, "M") != 0)
+ {
+ printf ("Enter a gender (M for male, F for female): ");
+ scanf ("%s", &sex);
+ }
+
+ FILE *FPaccout = fopen_ (account_txt, "r+");
+ fseek (FPaccout, 0, SEEK_END);
+ fprintf (FPaccout, "%i %s %s - %s -\r\n", next_id, username,
+ password, sex);
+ close (FPaccout);
+
+ printf ("Account added.\n");
}
diff --git a/src/tool/convert.c b/src/tool/convert.c
index b747116..154b154 100644
--- a/src/tool/convert.c
+++ b/src/tool/convert.c
@@ -8,289 +8,297 @@
#define MAX_SKILL 350
#define GLOBAL_REG_NUM 16
-struct item {
- int id;
- short nameid;
- short amount;
- short equip;
- char identify;
- char refine;
- char attribute;
- short card[4];
+struct item
+{
+ int id;
+ short nameid;
+ short amount;
+ short equip;
+ char identify;
+ char refine;
+ char attribute;
+ short card[4];
};
-struct point{
- char map[16];
- short x,y;
+struct point
+{
+ char map[16];
+ short x, y;
};
-struct skill {
- unsigned short id,lv,flag;
+struct skill
+{
+ unsigned short id, lv, flag;
};
-struct global_reg {
- char str[16];
- int value;
+struct global_reg
+{
+ char str[16];
+ int value;
};
-struct mmo_charstatus {
- int char_id;
- int account_id;
- int base_exp,job_exp,zeny;
+struct mmo_charstatus
+{
+ int char_id;
+ int account_id;
+ int base_exp, job_exp, zeny;
- short class;
- short status_point,skill_point;
- short hp,max_hp,sp,max_sp;
- short option,karma,manner;
- short hair,hair_color,clothes_color;
- int party_id,guild_id,pet_id;
+ short class;
+ short status_point, skill_point;
+ short hp, max_hp, sp, max_sp;
+ short option, karma, manner;
+ short hair, hair_color, clothes_color;
+ int party_id, guild_id, pet_id;
- short weapon,shield;
- short head_top,head_mid,head_bottom;
+ short weapon, shield;
+ short head_top, head_mid, head_bottom;
- char name[24];
- unsigned char base_level,job_level;
- unsigned char str,agi,vit,int_,dex,luk,char_num,sex;
+ char name[24];
+ unsigned char base_level, job_level;
+ unsigned char str, agi, vit, int_, dex, luk, char_num, sex;
- struct point last_point,save_point,memo_point[3];
- struct item inventory[MAX_INVENTORY],cart[MAX_CART];
- struct skill skill[MAX_SKILL];
- int global_reg_num;
- struct global_reg global_reg[GLOBAL_REG_NUM];
+ struct point last_point, save_point, memo_point[3];
+ struct item inventory[MAX_INVENTORY], cart[MAX_CART];
+ struct skill skill[MAX_SKILL];
+ int global_reg_num;
+ struct global_reg global_reg[GLOBAL_REG_NUM];
};
-int mmo_char_tostr(char *str,struct mmo_charstatus *p)
+int mmo_char_tostr (char *str, struct mmo_charstatus *p)
{
- int i;
- sprintf(str,"%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d"
- "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d"
- "\t%s,%d,%d\t%s,%d,%d",
- p->char_id,p->account_id,p->char_num,p->name, //
- p->class,p->base_level,p->job_level,
- p->base_exp,p->job_exp,p->zeny,
- p->hp,p->max_hp,p->sp,p->max_sp,
- p->str,p->agi,p->vit,p->int_,p->dex,p->luk,
- p->status_point,p->skill_point,
- p->option,p->karma,p->manner, //
- p->party_id,p->guild_id,p->pet_id,
- p->hair,p->hair_color,p->clothes_color,
- p->weapon,p->shield,p->head_top,p->head_mid,p->head_bottom,
- p->last_point.map,p->last_point.x,p->last_point.y, //
- p->save_point.map,p->save_point.x,p->save_point.y
- );
- strcat(str,"\t");
- for(i=0;i<3;i++)
- if(p->memo_point[i].map[0]){
- sprintf(str+strlen(str),"%s,%d,%d",p->memo_point[i].map,p->memo_point[i].x,p->memo_point[i].y);
- }
- strcat(str,"\t");
- for(i=0;i<MAX_INVENTORY;i++)
- if(p->inventory[i].nameid){
- sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip,
- p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute,
- p->inventory[i].card[0],p->inventory[i].card[1],p->inventory[i].card[2],p->inventory[i].card[3]);
- }
- strcat(str,"\t");
- for(i=0;i<MAX_CART;i++)
- if(p->cart[i].nameid){
- sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip,
- p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute,
- p->cart[i].card[0],p->cart[i].card[1],p->cart[i].card[2],p->cart[i].card[3]);
- }
- strcat(str,"\t");
- for(i=0;i<MAX_SKILL;i++)
- if(p->skill[i].id){
- sprintf(str+strlen(str),"%d,%d ",p->skill[i].id,p->skill[i].lv);
- }
- strcat(str,"\t");
- for(i=0;i<p->global_reg_num;i++)
- sprintf(str+strlen(str),"%s,%d ",p->global_reg[i].str,p->global_reg[i].value);
- strcat(str,"\t");
- return 0;
+ int i;
+ sprintf (str, "%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%s,%d,%d\t%s,%d,%d", p->char_id, p->account_id, p->char_num, p->name, //
+ p->class, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->hp, p->max_hp, p->sp, p->max_sp, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->status_point, p->skill_point, p->option, p->karma, p->manner, //
+ p->party_id, p->guild_id, p->pet_id, p->hair, p->hair_color, p->clothes_color, p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, p->last_point.map, p->last_point.x, p->last_point.y, //
+ p->save_point.map, p->save_point.x, p->save_point.y);
+ strcat (str, "\t");
+ for (i = 0; i < 3; i++)
+ if (p->memo_point[i].map[0])
+ {
+ sprintf (str + strlen (str), "%s,%d,%d", p->memo_point[i].map,
+ p->memo_point[i].x, p->memo_point[i].y);
+ }
+ strcat (str, "\t");
+ for (i = 0; i < MAX_INVENTORY; i++)
+ if (p->inventory[i].nameid)
+ {
+ sprintf (str + strlen (str), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
+ p->inventory[i].id, p->inventory[i].nameid,
+ p->inventory[i].amount, p->inventory[i].equip,
+ p->inventory[i].identify, p->inventory[i].refine,
+ p->inventory[i].attribute, p->inventory[i].card[0],
+ p->inventory[i].card[1], p->inventory[i].card[2],
+ p->inventory[i].card[3]);
+ }
+ strcat (str, "\t");
+ for (i = 0; i < MAX_CART; i++)
+ if (p->cart[i].nameid)
+ {
+ sprintf (str + strlen (str), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
+ p->cart[i].id, p->cart[i].nameid, p->cart[i].amount,
+ p->cart[i].equip, p->cart[i].identify, p->cart[i].refine,
+ p->cart[i].attribute, p->cart[i].card[0],
+ p->cart[i].card[1], p->cart[i].card[2],
+ p->cart[i].card[3]);
+ }
+ strcat (str, "\t");
+ for (i = 0; i < MAX_SKILL; i++)
+ if (p->skill[i].id)
+ {
+ sprintf (str + strlen (str), "%d,%d ", p->skill[i].id,
+ p->skill[i].lv);
+ }
+ strcat (str, "\t");
+ for (i = 0; i < p->global_reg_num; i++)
+ sprintf (str + strlen (str), "%s,%d ", p->global_reg[i].str,
+ p->global_reg[i].value);
+ strcat (str, "\t");
+ return 0;
}
-int mmo_char_fromstr(char *str,struct mmo_charstatus *p)
+int mmo_char_fromstr (char *str, struct mmo_charstatus *p)
{
- int tmp_int[256];
- int set,next,len,i;
+ int tmp_int[256];
+ int set, next, len, i;
- set=sscanf(str,"%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d"
- "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d"
- "\t%[^,],%d,%d\t%[^,],%d,%d%n",
- &tmp_int[0],&tmp_int[1],&tmp_int[2],p->name, //
- &tmp_int[3],&tmp_int[4],&tmp_int[5],
- &tmp_int[6],&tmp_int[7],&tmp_int[8],
- &tmp_int[9],&tmp_int[10],&tmp_int[11],&tmp_int[12],
- &tmp_int[13],&tmp_int[14],&tmp_int[15],&tmp_int[16],&tmp_int[17],&tmp_int[18],
- &tmp_int[19],&tmp_int[20],
- &tmp_int[21],&tmp_int[22],&tmp_int[23], //
- &tmp_int[24],&tmp_int[25],
- &tmp_int[26],&tmp_int[27],&tmp_int[28],
- &tmp_int[29],&tmp_int[30],&tmp_int[31],&tmp_int[32],&tmp_int[33],
- p->last_point.map,&tmp_int[34],&tmp_int[35], //
- p->save_point.map,&tmp_int[36],&tmp_int[37],&next
- );
- p->char_id=tmp_int[0];
- p->account_id=tmp_int[1];
- p->char_num=tmp_int[2];
- p->class=tmp_int[3];
- p->base_level=tmp_int[4];
- p->job_level=tmp_int[5];
- p->base_exp=tmp_int[6];
- p->job_exp=tmp_int[7];
- p->zeny=tmp_int[8];
- p->hp=tmp_int[9];
- p->max_hp=tmp_int[10];
- p->sp=tmp_int[11];
- p->max_sp=tmp_int[12];
- p->str=tmp_int[13];
- p->agi=tmp_int[14];
- p->vit=tmp_int[15];
- p->int_=tmp_int[16];
- p->dex=tmp_int[17];
- p->luk=tmp_int[18];
- p->status_point=tmp_int[19];
- p->skill_point=tmp_int[20];
- p->option=tmp_int[21];
- p->karma=tmp_int[22];
- p->manner=tmp_int[23];
- p->party_id=tmp_int[24];
- p->guild_id=tmp_int[25];
- p->pet_id=0;
- p->hair=tmp_int[26];
- p->hair_color=tmp_int[27];
- p->clothes_color=tmp_int[28];
- p->weapon=tmp_int[29];
- p->shield=tmp_int[30];
- p->head_top=tmp_int[31];
- p->head_mid=tmp_int[32];
- p->head_bottom=tmp_int[33];
- p->last_point.x=tmp_int[34];
- p->last_point.y=tmp_int[35];
- p->save_point.x=tmp_int[36];
- p->save_point.y=tmp_int[37];
- if(set!=41)
- return 0;
- if(str[next]=='\n' || str[next]=='\r')
- return 1; // 新規データ
- next++;
- for(i=0;str[next] && str[next]!='\t';i++){
- set=sscanf(str+next,"%[^,],%d,%d%n",p->memo_point[i].map,&tmp_int[0],&tmp_int[1],&len);
- if(set!=3)
- return 0;
- p->memo_point[i].x=tmp_int[0];
- p->memo_point[i].y=tmp_int[1];
- next+=len;
- if(str[next]==' ')
- next++;
- }
- next++;
- for(i=0;str[next] && str[next]!='\t';i++){
- set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0],&tmp_int[1],&tmp_int[2],&tmp_int[3],
- &tmp_int[4],&tmp_int[5],&tmp_int[6],
- &tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10],&len);
- if(set!=11)
- return 0;
- p->inventory[i].id=tmp_int[0];
- p->inventory[i].nameid=tmp_int[1];
- p->inventory[i].amount=tmp_int[2];
- p->inventory[i].equip=tmp_int[3];
- p->inventory[i].identify=tmp_int[4];
- p->inventory[i].refine=tmp_int[5];
- p->inventory[i].attribute=tmp_int[6];
- p->inventory[i].card[0]=tmp_int[7];
- p->inventory[i].card[1]=tmp_int[8];
- p->inventory[i].card[2]=tmp_int[9];
- p->inventory[i].card[3]=tmp_int[10];
- next+=len;
- if(str[next]==' ')
- next++;
- }
- next++;
- for(i=0;str[next] && str[next]!='\t';i++){
- set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0],&tmp_int[1],&tmp_int[2],&tmp_int[3],
- &tmp_int[4],&tmp_int[5],&tmp_int[6],
- &tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10],&len);
- if(set!=11)
- return 0;
- p->cart[i].id=tmp_int[0];
- p->cart[i].nameid=tmp_int[1];
- p->cart[i].amount=tmp_int[2];
- p->cart[i].equip=tmp_int[3];
- p->cart[i].identify=tmp_int[4];
- p->cart[i].refine=tmp_int[5];
- p->cart[i].attribute=tmp_int[6];
- p->cart[i].card[0]=tmp_int[7];
- p->cart[i].card[1]=tmp_int[8];
- p->cart[i].card[2]=tmp_int[9];
- p->cart[i].card[3]=tmp_int[10];
- next+=len;
- if(str[next]==' ')
- next++;
- }
- next++;
- for(i=0;str[next] && str[next]!='\t';i++){
- set=sscanf(str+next,"%d,%d%n",
- &tmp_int[0],&tmp_int[1],&len);
- if(set!=2)
- return 0;
- p->skill[tmp_int[0]].id=tmp_int[0];
- p->skill[tmp_int[0]].lv=tmp_int[1];
- next+=len;
- if(str[next]==' ')
- next++;
- }
- next++;
- for(i=0;str[next] && str[next]!='\t' && str[next]!='\n' && str[next]!='\r';i++){ //global_reg実装以前のathena.txt互換のため一応'\n'チェック
- set=sscanf(str+next,"%[^,],%d%n",
- p->global_reg[i].str,&p->global_reg[i].value,&len);
- if(set!=2)
- return 0;
- next+=len;
- if(str[next]==' ')
- next++;
- }
- p->global_reg_num=i;
- return 1;
+ set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
+ &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], //
+ &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], p->last_point.map, &tmp_int[34], &tmp_int[35], //
+ p->save_point.map, &tmp_int[36], &tmp_int[37], &next);
+ p->char_id = tmp_int[0];
+ p->account_id = tmp_int[1];
+ p->char_num = tmp_int[2];
+ p->class = tmp_int[3];
+ p->base_level = tmp_int[4];
+ p->job_level = tmp_int[5];
+ p->base_exp = tmp_int[6];
+ p->job_exp = tmp_int[7];
+ p->zeny = tmp_int[8];
+ p->hp = tmp_int[9];
+ p->max_hp = tmp_int[10];
+ p->sp = tmp_int[11];
+ p->max_sp = tmp_int[12];
+ p->str = tmp_int[13];
+ p->agi = tmp_int[14];
+ p->vit = tmp_int[15];
+ p->int_ = tmp_int[16];
+ p->dex = tmp_int[17];
+ p->luk = tmp_int[18];
+ p->status_point = tmp_int[19];
+ p->skill_point = tmp_int[20];
+ p->option = tmp_int[21];
+ p->karma = tmp_int[22];
+ p->manner = tmp_int[23];
+ p->party_id = tmp_int[24];
+ p->guild_id = tmp_int[25];
+ p->pet_id = 0;
+ p->hair = tmp_int[26];
+ p->hair_color = tmp_int[27];
+ p->clothes_color = tmp_int[28];
+ p->weapon = tmp_int[29];
+ p->shield = tmp_int[30];
+ p->head_top = tmp_int[31];
+ p->head_mid = tmp_int[32];
+ p->head_bottom = tmp_int[33];
+ p->last_point.x = tmp_int[34];
+ p->last_point.y = tmp_int[35];
+ p->save_point.x = tmp_int[36];
+ p->save_point.y = tmp_int[37];
+ if (set != 41)
+ return 0;
+ if (str[next] == '\n' || str[next] == '\r')
+ return 1; // 新規データ
+ next++;
+ for (i = 0; str[next] && str[next] != '\t'; i++)
+ {
+ set =
+ sscanf (str + next, "%[^,],%d,%d%n", p->memo_point[i].map,
+ &tmp_int[0], &tmp_int[1], &len);
+ if (set != 3)
+ return 0;
+ p->memo_point[i].x = tmp_int[0];
+ p->memo_point[i].y = tmp_int[1];
+ next += len;
+ if (str[next] == ' ')
+ next++;
+ }
+ next++;
+ for (i = 0; str[next] && str[next] != '\t'; i++)
+ {
+ set = sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
+ &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
+ &tmp_int[4], &tmp_int[5], &tmp_int[6],
+ &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
+ &len);
+ if (set != 11)
+ return 0;
+ p->inventory[i].id = tmp_int[0];
+ p->inventory[i].nameid = tmp_int[1];
+ p->inventory[i].amount = tmp_int[2];
+ p->inventory[i].equip = tmp_int[3];
+ p->inventory[i].identify = tmp_int[4];
+ p->inventory[i].refine = tmp_int[5];
+ p->inventory[i].attribute = tmp_int[6];
+ p->inventory[i].card[0] = tmp_int[7];
+ p->inventory[i].card[1] = tmp_int[8];
+ p->inventory[i].card[2] = tmp_int[9];
+ p->inventory[i].card[3] = tmp_int[10];
+ next += len;
+ if (str[next] == ' ')
+ next++;
+ }
+ next++;
+ for (i = 0; str[next] && str[next] != '\t'; i++)
+ {
+ set = sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
+ &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
+ &tmp_int[4], &tmp_int[5], &tmp_int[6],
+ &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
+ &len);
+ if (set != 11)
+ return 0;
+ p->cart[i].id = tmp_int[0];
+ p->cart[i].nameid = tmp_int[1];
+ p->cart[i].amount = tmp_int[2];
+ p->cart[i].equip = tmp_int[3];
+ p->cart[i].identify = tmp_int[4];
+ p->cart[i].refine = tmp_int[5];
+ p->cart[i].attribute = tmp_int[6];
+ p->cart[i].card[0] = tmp_int[7];
+ p->cart[i].card[1] = tmp_int[8];
+ p->cart[i].card[2] = tmp_int[9];
+ p->cart[i].card[3] = tmp_int[10];
+ next += len;
+ if (str[next] == ' ')
+ next++;
+ }
+ next++;
+ for (i = 0; str[next] && str[next] != '\t'; i++)
+ {
+ set = sscanf (str + next, "%d,%d%n", &tmp_int[0], &tmp_int[1], &len);
+ if (set != 2)
+ return 0;
+ p->skill[tmp_int[0]].id = tmp_int[0];
+ p->skill[tmp_int[0]].lv = tmp_int[1];
+ next += len;
+ if (str[next] == ' ')
+ next++;
+ }
+ next++;
+ for (i = 0;
+ str[next] && str[next] != '\t' && str[next] != '\n'
+ && str[next] != '\r'; i++)
+ { //global_reg実装以前のathena.txt互換のため一応'\n'チェック
+ set = sscanf (str + next, "%[^,],%d%n",
+ p->global_reg[i].str, &p->global_reg[i].value, &len);
+ if (set != 2)
+ return 0;
+ next += len;
+ if (str[next] == ' ')
+ next++;
+ }
+ p->global_reg_num = i;
+ return 1;
}
-int mmo_char_convert(char *fname1,char *fname2)
+int mmo_char_convert (char *fname1, char *fname2)
{
- char line[65536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp,*ofp;
+ char line[65536];
+ int ret;
+ struct mmo_charstatus char_dat;
+ FILE *ifp, *ofp;
- ifp=fopen_(fname1,"r");
- ofp=fopen_(fname2,"w");
- if(ifp==NULL) {
- printf("file not found %s\n",fname1);
- return 0;
- }
- if(ofp==NULL) {
- printf("file open error %s\n",fname2);
- return 0;
- }
- while(fgets(line,65535,ifp)){
- memset(&char_dat,0,sizeof(struct mmo_charstatus));
- ret=mmo_char_fromstr(line,&char_dat);
- if(ret){
- mmo_char_tostr(line,&char_dat);
- fprintf(ofp,"%s" RETCODE,line);
+ ifp = fopen_ (fname1, "r");
+ ofp = fopen_ (fname2, "w");
+ if (ifp == NULL)
+ {
+ printf ("file not found %s\n", fname1);
+ return 0;
+ }
+ if (ofp == NULL)
+ {
+ printf ("file open error %s\n", fname2);
+ return 0;
}
- }
- fcloseall();
- return 0;
+ while (fgets (line, 65535, ifp))
+ {
+ memset (&char_dat, 0, sizeof (struct mmo_charstatus));
+ ret = mmo_char_fromstr (line, &char_dat);
+ if (ret)
+ {
+ mmo_char_tostr (line, &char_dat);
+ fprintf (ofp, "%s" RETCODE, line);
+ }
+ }
+ fcloseall ();
+ return 0;
}
-int main(int argc,char *argv[])
+int main (int argc, char *argv[])
{
- if(argc < 3) {
- printf("Usage: convert <input filename> <output filename>\n");
- exit(0);
- }
- mmo_char_convert(argv[1],argv[2]);
+ if (argc < 3)
+ {
+ printf ("Usage: convert <input filename> <output filename>\n");
+ exit (0);
+ }
+ mmo_char_convert (argv[1], argv[2]);
- return 0;
+ return 0;
}
diff --git a/src/tool/itemfrob.c b/src/tool/itemfrob.c
index 999834c..bc9ff35 100644
--- a/src/tool/itemfrob.c
+++ b/src/tool/itemfrob.c
@@ -8,111 +8,128 @@
// Well, this is not terribly elegant, but I don't have that much time.
#define MAX_ITEM_ID 65535
-int inv_translate[MAX_ITEM_ID];
+int inv_translate[MAX_ITEM_ID];
-void
-transform_char(struct mmo_charstatus *p)
+void transform_char (struct mmo_charstatus *p)
{
- int k;
- for (k = 0; k < MAX_INVENTORY; k++)
- p->inventory[k].nameid = inv_translate[p->inventory[k].nameid];
+ int k;
+ for (k = 0; k < MAX_INVENTORY; k++)
+ p->inventory[k].nameid = inv_translate[p->inventory[k].nameid];
}
-int mmo_char_convert()
+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" RETCODE,line);
- }
+ 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" RETCODE, line);
}
- fcloseall();
- return 0;
+ }
+ fcloseall ();
+ return 0;
}
#define PARSE_MODE_NEXTNUM 0
#define PARSE_MODE_RANGE 1
-int init(char *source, char *dest)
+int init (char *source, char *dest)
{
- int i;
- char *end_of_num;
- int dest_nr = strtol(dest, &end_of_num, 0);
- int range_start;
- int mode = PARSE_MODE_NEXTNUM;
-
- if (*end_of_num) {
- fprintf(stderr, "Invalid inventory ID: `%s'\n", dest);
- return 1;
+ int i;
+ char *end_of_num;
+ int dest_nr = strtol (dest, &end_of_num, 0);
+ int range_start;
+ int mode = PARSE_MODE_NEXTNUM;
+
+ if (*end_of_num)
+ {
+ fprintf (stderr, "Invalid inventory ID: `%s'\n", dest);
+ return 1;
+ }
+
+ /* init */
+ for (i = 0; i < MAX_ITEM_ID; i++)
+ inv_translate[i] = i;
+
+ while (*source)
+ {
+ int nr = strtol (source, &end_of_num, 0);
+ char sep;
+
+ if (end_of_num == source)
+ {
+ fprintf (stderr, "Invalid source range description: `%s'\n",
+ source);
+ return 1;
}
- /* init */
- for (i = 0; i < MAX_ITEM_ID; i++)
- inv_translate[i] = i;
-
- while (*source) {
- int nr = strtol(source, &end_of_num, 0);
- char sep;
-
- if (end_of_num == source) {
- fprintf(stderr, "Invalid source range description: `%s'\n", source);
- return 1;
- }
-
- switch (mode) {
- case PARSE_MODE_NEXTNUM:
- inv_translate[nr] = dest_nr;
- break;
- case PARSE_MODE_RANGE:
- for (i = range_start; i <= nr; i++)
- inv_translate[i] = dest_nr;
- break;
- default: fprintf(stderr, "Internal error at %d\n", __LINE__);
- return 1;
- };
-
- sep = *end_of_num++;
-
- switch (sep) {
- case '-':
- range_start = nr;
- mode = PARSE_MODE_RANGE; break;
- case ',': mode = PARSE_MODE_NEXTNUM; break;
- case 0: return 0;
- default: fprintf(stderr, "Invalid token in range spec: `%c'\n", sep);
- return 1;
- }
-
- source = end_of_num;
+ switch (mode)
+ {
+ case PARSE_MODE_NEXTNUM:
+ inv_translate[nr] = dest_nr;
+ break;
+ case PARSE_MODE_RANGE:
+ for (i = range_start; i <= nr; i++)
+ inv_translate[i] = dest_nr;
+ break;
+ default:
+ fprintf (stderr, "Internal error at %d\n", __LINE__);
+ return 1;
+ };
+
+ sep = *end_of_num++;
+
+ switch (sep)
+ {
+ case '-':
+ range_start = nr;
+ mode = PARSE_MODE_RANGE;
+ break;
+ case ',':
+ mode = PARSE_MODE_NEXTNUM;
+ break;
+ case 0:
+ return 0;
+ default:
+ fprintf (stderr, "Invalid token in range spec: `%c'\n", sep);
+ return 1;
}
- return 0;
+
+ source = end_of_num;
+ }
+ return 0;
}
-int main(int argc,char *argv[])
+int main (int argc, char *argv[])
{
- if(argc < 3) {
- printf("Usage: %s <inventory ID input range> <inventory ID output>\n", argv[0]);
- printf("e.g., %s 501-555 701\n", argv[0]);
- exit(0);
- }
- if (init(argv[1], argv[2]))
- return 1;
-
- mmo_char_convert();
-
- return 0;
+ if (argc < 3)
+ {
+ printf
+ ("Usage: %s <inventory ID input range> <inventory ID output>\n",
+ argv[0]);
+ printf ("e.g., %s 501-555 701\n", argv[0]);
+ exit (0);
+ }
+ if (init (argv[1], argv[2]))
+ return 1;
+
+ mmo_char_convert ();
+
+ return 0;
}
-
/* satisfy linker */
-void set_termfunc(void (*termfunc)(void)) {};
+void set_termfunc (void (*termfunc) (void))
+{
+};
diff --git a/src/tool/mapfrob.c b/src/tool/mapfrob.c
index 7173f0b..d410878 100644
--- a/src/tool/mapfrob.c
+++ b/src/tool/mapfrob.c
@@ -9,118 +9,126 @@
// Well, this is not terribly elegant, but I don't have that much time.
#define MAX_MAP 1024
#define MAP_NAME_SIZE 32
-int maps_nr = 0;
-struct {
+int maps_nr = 0;
+struct
+{
char old[MAP_NAME_SIZE], new[MAP_NAME_SIZE];
} maps[MAX_MAP];
-void
-transform_point(struct point *p)
+void transform_point (struct point *p)
{
- int k;
+ int k;
- if (!p->map[0])
- return;
+ if (!p->map[0])
+ return;
- for (k = 0; k < maps_nr; k++)
- if (!strcmp(p->map, maps[k].old)) {
- strcpy(p->map, maps[k].new);
- return;
- }
+ for (k = 0; k < maps_nr; k++)
+ if (!strcmp (p->map, maps[k].old))
+ {
+ strcpy (p->map, maps[k].new);
+ return;
+ }
- fprintf(stderr, "Warning: untranslated map `%s'\n", p->map);
+ fprintf (stderr, "Warning: untranslated map `%s'\n", p->map);
}
-void
-transform_char(struct mmo_charstatus *p)
+void transform_char (struct mmo_charstatus *p)
{
- int i;
+ int i;
- transform_point(&p->last_point);
- transform_point(&p->save_point);
+ transform_point (&p->last_point);
+ transform_point (&p->save_point);
- for (i = 0; i < 10; i++)
- transform_point(&p->memo_point[i]);
+ for (i = 0; i < 10; i++)
+ transform_point (&p->memo_point[i]);
}
-int mmo_char_convert()
+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" RETCODE,line);
- }
+ 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" RETCODE, line);
}
- fcloseall();
- return 0;
+ }
+ fcloseall ();
+ return 0;
}
#define PARSE_MODE_NEXTNUM 0
#define PARSE_MODE_RANGE 1
-int init(int count, char **translates)
+int init (int count, char **translates)
{
- int i;
- char *suffix = ".gat";
-
- for (i = 0; i < count; i++) {
- char *src = translates[i];
- char *dest = strchr(src, ':');
-
- if (!dest) {
- fprintf(stderr, "Missing colon in: `%s'\n", src);
- return 1;
- }
+ int i;
+ char *suffix = ".gat";
+
+ for (i = 0; i < count; i++)
+ {
+ char *src = translates[i];
+ char *dest = strchr (src, ':');
+
+ if (!dest)
+ {
+ fprintf (stderr, "Missing colon in: `%s'\n", src);
+ return 1;
+ }
- *dest++ = 0;
+ *dest++ = 0;
- if (strlen(src) + strlen(suffix) >= MAP_NAME_SIZE) {
- fprintf(stderr, "Map name prefix too long: `%s'\n", src);
- return 1;
- }
+ if (strlen (src) + strlen (suffix) >= MAP_NAME_SIZE)
+ {
+ fprintf (stderr, "Map name prefix too long: `%s'\n", src);
+ return 1;
+ }
- if (strlen(dest) + strlen(suffix) >= MAP_NAME_SIZE) {
- fprintf(stderr, "Map name prefix too long: `%s'\n", dest);
- return 1;
- }
+ if (strlen (dest) + strlen (suffix) >= MAP_NAME_SIZE)
+ {
+ fprintf (stderr, "Map name prefix too long: `%s'\n", dest);
+ return 1;
+ }
- strncpy(maps[maps_nr].old, src, MAP_NAME_SIZE);
- strcat(maps[maps_nr].old, suffix);
- strncpy(maps[maps_nr].new, dest, MAP_NAME_SIZE);
- strcat(maps[maps_nr].new, suffix);
+ strncpy (maps[maps_nr].old, src, MAP_NAME_SIZE);
+ strcat (maps[maps_nr].old, suffix);
+ strncpy (maps[maps_nr].new, dest, MAP_NAME_SIZE);
+ strcat (maps[maps_nr].new, suffix);
- ++maps_nr;
- }
+ ++maps_nr;
+ }
- return 0;
+ return 0;
}
-int main(int argc,char *argv[])
+int main (int argc, char *argv[])
{
- if(argc < 2) {
- printf("Usage: %s oldmap0:newmap0 oldmap1:newmap1 ...\n", argv[0]);
- printf("e.g., %s new_1-1:001-2 new_2-1:001-1\n", argv[0]);
- puts("The extension `.gat' is appended implicitly.");
- exit(0);
- }
- if (init(argc - 1, argv + 1))
- return 1;
-
- mmo_char_convert();
-
- return 0;
+ if (argc < 2)
+ {
+ printf ("Usage: %s oldmap0:newmap0 oldmap1:newmap1 ...\n", argv[0]);
+ printf ("e.g., %s new_1-1:001-2 new_2-1:001-1\n", argv[0]);
+ puts ("The extension `.gat' is appended implicitly.");
+ exit (0);
+ }
+ if (init (argc - 1, argv + 1))
+ return 1;
+
+ mmo_char_convert ();
+
+ return 0;
}
-
/* satisfy linker */
-void set_termfunc(void (*termfunc)(void)) {};
+void set_termfunc (void (*termfunc) (void))
+{
+};
diff --git a/src/tool/skillfrob.c b/src/tool/skillfrob.c
index 3d6132c..ea68660 100644
--- a/src/tool/skillfrob.c
+++ b/src/tool/skillfrob.c
@@ -8,72 +8,78 @@
unsigned char skills[MAX_SKILL];
-void transform_char(struct mmo_charstatus *p)
+void transform_char (struct mmo_charstatus *p)
{
- int i;
+ 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;
- }
- }
+ 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()
+int mmo_char_convert ()
{
- char line[965536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp,*ofp;
+ 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" RETCODE,line);
- }
+ 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" RETCODE, line);
}
- fcloseall();
- return 0;
+ }
+ fcloseall ();
+ return 0;
}
-int init(int count, char **translates)
+int init (int count, char **translates)
{
- int i, skill;
+ int i, skill;
- memset(skills, 0, sizeof(skills));
+ memset (skills, 0, sizeof (skills));
- for (i = 0; i < count; i++) {
- skill = atoi(translates[i]);
- if (skill > 0)
- {
- skills[skill] = 1;
- }
+ for (i = 0; i < count; i++)
+ {
+ skill = atoi (translates[i]);
+ if (skill > 0)
+ {
+ skills[skill] = 1;
}
+ }
- return 0;
+ return 0;
}
-int main(int argc,char *argv[])
+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;
+ if (argc < 2)
+ {
+ printf ("Usage: %s skillid1 skillid2 ...\n", argv[0]);
+ exit (0);
+ }
+ if (init (argc - 1, argv + 1))
+ return 1;
- mmo_char_convert();
+ mmo_char_convert ();
- return 0;
+ return 0;
}
/* satisfy linker */
-void set_termfunc(void (*termfunc)(void)) {};
+void set_termfunc (void (*termfunc) (void))
+{
+};