summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorveider <veider@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-28 21:25:11 +0000
committerveider <veider@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-28 21:25:11 +0000
commitcb44aff61ed172eb338535078d772090b124d465 (patch)
tree68efd87328d3c019577d968833a44b588270c28b /src/char_sql
parent00fb4a56f6ae894e84cdd62faf6bf596a097e0e0 (diff)
downloadhercules-cb44aff61ed172eb338535078d772090b124d465.tar.gz
hercules-cb44aff61ed172eb338535078d772090b124d465.tar.bz2
hercules-cb44aff61ed172eb338535078d772090b124d465.tar.xz
hercules-cb44aff61ed172eb338535078d772090b124d465.zip
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1316 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/char.c70
-rw-r--r--src/char_sql/char.h4
-rw-r--r--src/char_sql/int_party.c36
3 files changed, 95 insertions, 15 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 6b122974f..0d3fc3d35 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -415,7 +415,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){
(p->clothes_color != cp->clothes_color) || (p->weapon != cp->weapon) ||
(p->shield != cp->shield) || (p->head_top != cp->head_top) ||
(p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) ||
- (p->partner_id != cp->partner_id)) {
+ (p->partner_id != cp->partner_id) || (p->father != cp->father) ||
+ (p->mother != cp->mother) || (p->child != cp->child)) {
//}//---------------------------test count------------------------------
//check party_exist
@@ -457,7 +458,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
"`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',"
"`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
- "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d',`partner_id`='%d' WHERE `account_id`='%d' AND `char_id` = '%d'",
+ "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d',`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d' WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->class_, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point,
@@ -466,7 +467,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){
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, p->partner_id, p->account_id, p->char_id
+ p->save_point.map, p->save_point.x, p->save_point.y, p->partner_id, p->father, p->mother,
+ p->child, p->account_id, p->char_id
);
if(mysql_query(&mysql_handle, tmp_sql)) {
@@ -799,7 +801,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){
sprintf(tmp_sql, "SELECT `option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`hair`,`hair_color`,"
"`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,"
- "`last_map`,`last_x`,`last_y`,`save_map`,`save_x`,`save_y`, `partner_id` FROM `%s` WHERE `char_id` = '%d'",char_db, char_id); // TBR
+ "`last_map`,`last_x`,`last_y`,`save_map`,`save_x`,`save_y`, `partner_id`, `father`, `mother`, `child` FROM `%s` WHERE `char_id` = '%d'",char_db, char_id); // TBR
if (mysql_query(&mysql_handle, tmp_sql)) {
printf("DB server Error (select `char2`)- %s\n", mysql_error(&mysql_handle));
}
@@ -817,7 +819,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){
p->head_top = atoi(sql_row[11]); p->head_mid = atoi(sql_row[12]); p->head_bottom = atoi(sql_row[13]);
strcpy(p->last_point.map,sql_row[14]); p->last_point.x = atoi(sql_row[15]); p->last_point.y = atoi(sql_row[16]);
strcpy(p->save_point.map,sql_row[17]); p->save_point.x = atoi(sql_row[18]); p->save_point.y = atoi(sql_row[19]);
- p->partner_id = atoi(sql_row[20]);
+ p->partner_id = atoi(sql_row[20]); p->father = atoi(sql_row[21]); p->mother = atoi(sql_row[22]); p->child = atoi(sql_row[23]);
//free mysql result.
mysql_free_result(sql_res);
@@ -3564,3 +3566,61 @@ int debug_mysql_query(char *file, int line, void *mysql, const char *q) {
#endif
return mysql_query((MYSQL *) mysql, q);
}
+
+int char_child(int parent_id, int child_id) {
+ int tmp_id = 0;
+ sprintf (tmp_sql, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id);
+ if (mysql_query (&mysql_handle, tmp_sql)) {
+ printf ("DB server Error (select `char2`)- %s\n", mysql_error (&mysql_handle));
+ }
+ sql_res = mysql_store_result (&mysql_handle);
+ if (sql_res) {
+ sql_row = mysql_fetch_row (sql_res);
+ tmp_id = atoi (sql_row[0]);
+ mysql_free_result (sql_res);
+ }
+ else
+ printf("CHAR: child Failed!\n");
+ if ( tmp_id == child_id )
+ return 1;
+ else
+ return 0;
+}
+
+int char_married(int pl1,int pl2) {
+ int tmp_id = 0;
+ sprintf (tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1);
+ if (mysql_query (&mysql_handle, tmp_sql)) {
+ printf ("DB server Error (select `char2`)- %s\n", mysql_error (&mysql_handle));
+ }
+ sql_res = mysql_store_result (&mysql_handle);
+ if (sql_res) {
+ sql_row = mysql_fetch_row (sql_res);
+ tmp_id = atoi (sql_row[0]);
+ mysql_free_result (sql_res);
+ }
+ else
+ printf("CHAR: married Failed!\n");
+ if ( tmp_id == pl2 )
+ return 1;
+ else
+ return 0;
+}
+
+int char_nick2id (char *name) {
+ int char_id = 0;
+ sprintf (tmp_sql, "SELECT `char_id` FROM `%s` WHERE `name` = '%s'", char_db, name);
+ if (mysql_query (&mysql_handle, tmp_sql)) {
+ printf ("DB server Error (select `char2`)- %s\n", mysql_error (&mysql_handle));
+ }
+ sql_res = mysql_store_result (&mysql_handle);
+ if (sql_res) {
+ sql_row = mysql_fetch_row (sql_res);
+ char_id = atoi (sql_row[0]);
+ mysql_free_result (sql_res);
+ }
+ else
+ printf ("CHAR: nick2id Failed!\n");
+ return char_id;
+}
+
diff --git a/src/char_sql/char.h b/src/char_sql/char.h
index 81ce65b8e..74bb28cf1 100644
--- a/src/char_sql/char.h
+++ b/src/char_sql/char.h
@@ -45,6 +45,10 @@ int mapif_sendall(unsigned char *buf,unsigned int len);
int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
int mapif_send(int fd,unsigned char *buf,unsigned int len);
+int char_nick2id (char *name);
+int char_married(int pl1,int pl2);
+int char_child(int parent_id, int child_id);
+
extern int autosave_interval;
extern char db_path[];
extern char char_db[256];
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index 03392feb6..430385110 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -293,16 +293,32 @@ struct party* search_partyname(char *str)
// EXP公平分配できるかチェック
int party_check_exp_share(struct party *p)
{
- int i;
- int maxlv=0,minlv=0x7fffffff;
- for(i=0;i<MAX_PARTY;i++){
- int lv=p->member[i].lv;
- if( p->member[i].online ){
- if( lv < minlv ) minlv=lv;
- if( maxlv < lv ) maxlv=lv;
- }
- }
- return (maxlv==0 || maxlv-minlv<=party_share_level);
+ int i, dudes=0;
+ int pl1=0,pl2=0,pl3=0;
+ int maxlv=0,minlv=0x7fffffff;
+ for(i=0;i<MAX_PARTY;i++){
+ int lv=p->member[i].lv;
+ if (!lv) continue;
+ if( p->member[i].online ){
+ if( lv < minlv ) minlv=lv;
+ if( maxlv < lv ) maxlv=lv;
+ if( lv >= 70 ) dudes+=1000;
+ dudes++;
+ }
+ }
+ if((dudes/1000 >= 2) && (dudes%1000 == 3) && (!strcmp(p->member[0].map,p->member[1].map)) && (!strcmp(p->member[1].map,p->member[2].map))) {
+ pl1=char_nick2id(p->member[0].name);
+ pl2=char_nick2id(p->member[1].name);
+ pl3=char_nick2id(p->member[2].name);
+ printf("PARTY: group of 3 Id1 %d lv %d name %s Id2 %d lv %d name %s Id3 %d lv %d name %s\n",pl1,p->member[0].lv,p->member[0].name,pl2,p->member[1].lv,p->member[1].name,pl3,p->member[2].lv,p->member[2].name);
+ if (char_married(pl1,pl2) && char_child(pl1,pl3))
+ return 1;
+ if (char_married(pl1,pl3) && char_child(pl1,pl2))
+ return 1;
+ if (char_married(pl2,pl3) && char_child(pl2,pl1))
+ return 1;
+ }
+ return (maxlv==0 || maxlv-minlv<=party_share_level);
}
// Is there any member in the party?
int party_check_empty(struct party *p)