summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-08 15:18:32 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-08 15:18:32 -0600
commitc8da743b969b251bab107125d4af82ec7f4e376c (patch)
tree6d499634d8dcd49d80ae869cb28cca58893b1160 /src/char
parent23c6c0e2c8b10bbecf1e673723914618170ac551 (diff)
downloadtmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.gz
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.bz2
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.xz
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.zip
Strip some more out
Diffstat (limited to 'src/char')
-rw-r--r--src/char/Makefile7
-rw-r--r--src/char/char.c14
-rw-r--r--src/char/int_pet.c364
-rw-r--r--src/char/int_pet.h13
-rw-r--r--src/char/int_storage.c11
-rw-r--r--src/char/inter.c7
6 files changed, 5 insertions, 411 deletions
diff --git a/src/char/Makefile b/src/char/Makefile
index 65e2eb4..d4344a0 100644
--- a/src/char/Makefile
+++ b/src/char/Makefile
@@ -3,15 +3,14 @@ txt: char-server
COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o
COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h
-char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ)
+char-server: char.o inter.o int_party.o int_guild.o int_storage.o $(COMMON_OBJ)
$(CC) -o ../../$@ $>
-char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h
-inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H)
+char.o: char.c char.h inter.h $(COMMON_H) ../common/version.h
+inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h char.h $(COMMON_H)
int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H)
int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H)
int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H)
-int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H)
clean:
rm -f *.o ../../char-server
diff --git a/src/char/char.c b/src/char/char.c
index 7512dd0..27ef4c8 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -26,7 +26,6 @@
#include "char.h"
#include "inter.h"
-#include "int_pet.h"
#include "int_guild.h"
#include "int_party.h"
#include "int_storage.h"
@@ -237,7 +236,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p) {
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->party_id, p->guild_id, 0,
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, //
@@ -384,7 +383,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) {
p->manner = tmp_int[23];
p->party_id = tmp_int[24];
p->guild_id = tmp_int[25];
- p->pet_id = tmp_int[26];
+// p->pet_id = tmp_int[26];
p->hair = tmp_int[27];
p->hair_color = tmp_int[28];
p->clothes_color = tmp_int[29];
@@ -1470,15 +1469,6 @@ int disconnect_player(int accound_id) {
static int char_delete(struct mmo_charstatus *cs) {
int j;
- // ペット削除
- if (cs->pet_id)
- inter_pet_delete(cs->pet_id);
- for (j = 0; j < MAX_INVENTORY; j++)
- if (cs->inventory[j].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&cs->inventory[j].card[2])));
- for (j = 0; j < MAX_CART; j++)
- if (cs->cart[j].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&cs->cart[j].card[2])));
// ギルド脱退
if (cs->guild_id)
inter_guild_leave(cs->guild_id, cs->account_id, cs->char_id);
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
deleted file mode 100644
index cff1e43..0000000
--- a/src/char/int_pet.c
+++ /dev/null
@@ -1,364 +0,0 @@
-// $Id: int_pet.c,v 1.1.1.1 2004/09/10 17:26:51 MagicalTux Exp $
-#include "inter.h"
-#include "int_pet.h"
-#include "mmo.h"
-#include "char.h"
-#include "socket.h"
-#include "db.h"
-#include "lock.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-char pet_txt[1024]="save/pet.txt";
-
-static struct dbt *pet_db;
-static int pet_newid = 100;
-
-int inter_pet_tostr(char *str,struct s_pet *p)
-{
- int len;
-
- if(p->hungry < 0)
- p->hungry = 0;
- else if(p->hungry > 100)
- p->hungry = 100;
- if(p->intimate < 0)
- p->intimate = 0;
- else if(p->intimate > 1000)
- p->intimate = 1000;
-
- len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d",
- p->pet_id,p->class,p->name,p->account_id,p->char_id,p->level,p->egg_id,
- p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate);
-
- return 0;
-}
-
-int inter_pet_fromstr(char *str,struct s_pet *p)
-{
- int s;
- int tmp_int[16];
- char tmp_str[256];
-
- memset(p,0,sizeof(struct s_pet));
-
-// printf("sscanf pet main info\n");
- s=sscanf(str,"%d,%d,%[^\t]\t%d,%d,%d,%d,%d,%d,%d,%d,%d",&tmp_int[0],&tmp_int[1],tmp_str,&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]);
-
- if(s!=12)
- return 1;
-
- p->pet_id = tmp_int[0];
- p->class = tmp_int[1];
- memcpy(p->name,tmp_str,24);
- p->account_id = tmp_int[2];
- p->char_id = tmp_int[3];
- p->level = tmp_int[4];
- p->egg_id = tmp_int[5];
- p->equip = tmp_int[6];
- p->intimate = tmp_int[7];
- p->hungry = tmp_int[8];
- p->rename_flag = tmp_int[9];
- p->incuvate = tmp_int[10];
-
- if(p->hungry < 0)
- p->hungry = 0;
- else if(p->hungry > 100)
- p->hungry = 100;
- if(p->intimate < 0)
- p->intimate = 0;
- else if(p->intimate > 1000)
- p->intimate = 1000;
-
- return 0;
-}
-
-int inter_pet_init()
-{
- char line[8192];
- struct s_pet *p;
- FILE *fp;
- int c=0;
-
- pet_db=numdb_init();
-
- if( (fp=fopen(pet_txt,"r"))==NULL )
- return 1;
- while(fgets(line,sizeof(line),fp)){
- p=calloc(sizeof(struct s_pet), 1);
- if(p==NULL){
- printf("int_pet: out of memory!\n");
- exit(0);
- }
- memset(p,0,sizeof(struct s_pet));
- if(inter_pet_fromstr(line,p)==0 && p->pet_id>0){
- if( p->pet_id >= pet_newid)
- pet_newid=p->pet_id+1;
- numdb_insert(pet_db,p->pet_id,p);
- }else{
- printf("int_pet: broken data [%s] line %d\n",pet_txt,c);
- free(p);
- }
- c++;
- }
- fclose(fp);
-// printf("int_pet: %s read done (%d pets)\n",pet_txt,c);
- return 0;
-}
-
-int inter_pet_save_sub(void *key,void *data,va_list ap)
-{
- char line[8192];
- FILE *fp;
- inter_pet_tostr(line,(struct s_pet *)data);
- fp=va_arg(ap,FILE *);
- fprintf(fp,"%s" RETCODE,line);
- return 0;
-}
-
-int inter_pet_save()
-{
- FILE *fp;
- int lock;
- if( (fp=lock_fopen(pet_txt,&lock))==NULL ){
- printf("int_pet: cant write [%s] !!! data is lost !!!\n",pet_txt);
- return 1;
- }
- numdb_foreach(pet_db,inter_pet_save_sub,fp);
- lock_fclose(fp,pet_txt,&lock);
-// printf("int_pet: %s saved.\n",pet_txt);
- return 0;
-}
-
-int inter_pet_delete(int pet_id)
-{
- struct s_pet *p;
- p = numdb_search(pet_db,pet_id);
- if( p == NULL)
- return 1;
- else {
- numdb_erase(pet_db,pet_id);
- printf("pet_id: %d deleted\n",pet_id);
- }
- return 0;
-}
-
-int mapif_pet_created(int fd,int account_id,struct s_pet *p)
-{
- WFIFOW(fd,0)=0x3880;
- WFIFOL(fd,2)=account_id;
- if(p!=NULL){
- WFIFOB(fd,6)=0;
- WFIFOL(fd,7)=p->pet_id;
- printf("int_pet: created! %d %s\n",p->pet_id,p->name);
- }else{
- WFIFOB(fd,6)=1;
- WFIFOL(fd,7)=0;
- }
- WFIFOSET(fd,11);
-
- return 0;
-}
-
-int mapif_pet_info(int fd,int account_id,struct s_pet *p)
-{
- WFIFOW(fd,0)=0x3881;
- WFIFOW(fd,2)=sizeof(struct s_pet) + 9;
- WFIFOL(fd,4)=account_id;
- WFIFOB(fd,8)=0;
- memcpy(WFIFOP(fd,9),p,sizeof(struct s_pet));
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-int mapif_pet_noinfo(int fd,int account_id)
-{
- WFIFOW(fd,0)=0x3881;
- WFIFOW(fd,2)=sizeof(struct s_pet) + 9;
- WFIFOL(fd,4)=account_id;
- WFIFOB(fd,8)=1;
- memset(WFIFOP(fd,9),0,sizeof(struct s_pet));
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-int mapif_save_pet_ack(int fd,int account_id,int flag)
-{
- WFIFOW(fd,0)=0x3882;
- WFIFOL(fd,2)=account_id;
- WFIFOB(fd,6)=flag;
- WFIFOSET(fd,7);
-
- return 0;
-}
-
-int mapif_delete_pet_ack(int fd,int flag)
-{
- WFIFOW(fd,0)=0x3883;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,3);
-
- return 0;
-}
-
-int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
- short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
-{
- struct s_pet *p;
- p=malloc(sizeof(struct s_pet));
- if(p==NULL){
- printf("int_pet: out of memory !\n");
- mapif_pet_created(fd,account_id,NULL);
- return 0;
- }
- memset(p,0,sizeof(struct s_pet));
- p->pet_id = pet_newid++;
- memcpy(p->name,pet_name,24);
- if(incuvate == 1)
- p->account_id = p->char_id = 0;
- else {
- p->account_id = account_id;
- p->char_id = char_id;
- }
- p->class = pet_class;
- p->level = pet_lv;
- p->egg_id = pet_egg_id;
- p->equip = pet_equip;
- p->intimate = intimate;
- p->hungry = hungry;
- p->rename_flag = rename_flag;
- p->incuvate = incuvate;
-
- if(p->hungry < 0)
- p->hungry = 0;
- else if(p->hungry > 100)
- p->hungry = 100;
- if(p->intimate < 0)
- p->intimate = 0;
- else if(p->intimate > 1000)
- p->intimate = 1000;
-
- numdb_insert(pet_db,p->pet_id,p);
-
- mapif_pet_created(fd,account_id,p);
-
- return 0;
-}
-
-int mapif_load_pet(int fd,int account_id,int char_id,int pet_id)
-{
- struct s_pet *p;
- p=numdb_search(pet_db,pet_id);
- if(p!=NULL) {
- if(p->incuvate == 1) {
- p->account_id = p->char_id = 0;
- mapif_pet_info(fd,account_id,p);
- }
- else if(account_id == p->account_id && char_id == p->char_id)
- mapif_pet_info(fd,account_id,p);
- else
- mapif_pet_noinfo(fd,account_id);
- }
- else
- mapif_pet_noinfo(fd,account_id);
-
- return 0;
-}
-
-int mapif_save_pet(int fd,int account_id,struct s_pet *data)
-{
- struct s_pet *p;
- int pet_id;
- int len=RFIFOW(fd,2);
- if(sizeof(struct s_pet)!=len-8) {
- printf("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8);
- }
- else{
- pet_id = data->pet_id;
- p=numdb_search(pet_db,pet_id);
- if(p == NULL) {
- p=malloc(sizeof(struct s_pet));
- if(p==NULL){
- printf("int_pet: out of memory !\n");
- mapif_save_pet_ack(fd,account_id,1);
- return 0;
- }
- memset(p,0,sizeof(struct s_pet));
- p->pet_id = data->pet_id;
- if(p->pet_id == 0)
- data->pet_id = p->pet_id = pet_newid++;
- numdb_insert(pet_db,p->pet_id,p);
- }
- if(data->hungry < 0)
- data->hungry = 0;
- else if(data->hungry > 100)
- data->hungry = 100;
- if(data->intimate < 0)
- data->intimate = 0;
- else if(data->intimate > 1000)
- data->intimate = 1000;
- memcpy(p,data,sizeof(struct s_pet));
- if(p->incuvate == 1)
- p->account_id = p->char_id = 0;
-
- mapif_save_pet_ack(fd,account_id,0);
- }
-
- return 0;
-}
-
-int mapif_delete_pet(int fd,int pet_id)
-{
- mapif_delete_pet_ack(fd,inter_pet_delete(pet_id));
-
- return 0;
-}
-
-int mapif_parse_CreatePet(int fd)
-{
- mapif_create_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOW(fd,14),RFIFOW(fd,16),RFIFOL(fd,18),
- RFIFOL(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),RFIFOP(fd,24));
- return 0;
-}
-
-int mapif_parse_LoadPet(int fd)
-{
- mapif_load_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- return 0;
-}
-
-int mapif_parse_SavePet(int fd)
-{
- mapif_save_pet(fd,RFIFOL(fd,4),(struct s_pet *)RFIFOP(fd,8));
- return 0;
-}
-
-int mapif_parse_DeletePet(int fd)
-{
- mapif_delete_pet(fd,RFIFOL(fd,2));
- return 0;
-}
-
-// map server からの通信
-// ・1パケットのみ解析すること
-// ・パケット長データはinter.cにセットしておくこと
-// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
-// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
-int inter_pet_parse_frommap(int fd)
-{
- switch(RFIFOW(fd,0)){
- case 0x3080: mapif_parse_CreatePet(fd); break;
- case 0x3081: mapif_parse_LoadPet(fd); break;
- case 0x3082: mapif_parse_SavePet(fd); break;
- case 0x3083: mapif_parse_DeletePet(fd); break;
- default:
- return 0;
- }
- return 1;
-}
-
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
deleted file mode 100644
index 993f913..0000000
--- a/src/char/int_pet.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// $Id: int_pet.h,v 1.1.1.1 2004/09/10 17:26:51 MagicalTux Exp $
-#ifndef _INT_PET_H_
-#define _INT_PET_H_
-
-int inter_pet_init();
-int inter_pet_save();
-int inter_pet_delete(int pet_id);
-
-int inter_pet_parse_frommap(int fd);
-
-extern char pet_txt[1024];
-
-#endif
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 8b656fc..b84b586 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -1,7 +1,6 @@
// $Id: int_storage.c,v 1.1.1.1 2004/09/10 17:26:51 MagicalTux Exp $
#include "inter.h"
#include "int_storage.h"
-#include "int_pet.h"
#include "int_guild.h"
#include "mmo.h"
#include "char.h"
@@ -354,11 +353,6 @@ int inter_storage_delete(int account_id)
{
struct storage *s = numdb_search(storage_db,account_id);
if(s) {
- int i;
- for(i=0;i<s->storage_amount;i++){
- if(s->storage[i].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&s->storage[i].card[2])));
- }
numdb_erase(storage_db,account_id);
free(s);
}
@@ -370,11 +364,6 @@ int inter_guild_storage_delete(int guild_id)
{
struct guild_storage *gs = numdb_search(guild_storage_db,guild_id);
if(gs) {
- int i;
- for(i=0;i<gs->storage_amount;i++){
- if(gs->storage[i].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&gs->storage[i].card[2])));
- }
numdb_erase(guild_storage_db,guild_id);
free(gs);
}
diff --git a/src/char/inter.c b/src/char/inter.c
index 29ec57b..98e7ad0 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -11,7 +11,6 @@
#include "int_party.h"
#include "int_guild.h"
#include "int_storage.h"
-#include "int_pet.h"
#include "lock.h"
#define WISDATA_TTL (60*1000) // Existence time of Wisp/page data (60 seconds)
@@ -193,8 +192,6 @@ int inter_config_read(const char *cfgName) {
strncpy(party_txt, w2, sizeof(party_txt));
} else if (strcmpi(w1, "guild_txt") == 0) {
strncpy(guild_txt, w2, sizeof(guild_txt));
- } else if (strcmpi(w1, "pet_txt") == 0) {
- strncpy(pet_txt, w2, sizeof(pet_txt));
} else if (strcmpi(w1, "castle_txt") == 0) {
strncpy(castle_txt, w2, sizeof(castle_txt));
} else if (strcmpi(w1, "accreg_txt") == 0) {
@@ -238,7 +235,6 @@ int inter_save() {
inter_guild_save();
inter_storage_save();
inter_guild_storage_save();
- inter_pet_save();
inter_accreg_save();
return 0;
@@ -253,7 +249,6 @@ int inter_init(const char *file) {
inter_party_init();
inter_guild_init();
inter_storage_init();
- inter_pet_init();
inter_accreg_init();
return 0;
@@ -535,8 +530,6 @@ int inter_parse_frommap(int fd) {
break;
if (inter_storage_parse_frommap(fd))
break;
- if (inter_pet_parse_frommap(fd))
- break;
return 0;
}
RFIFOSKIP(fd, len);