summaryrefslogtreecommitdiff
path: root/src/char_sql/int_party.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-30 21:54:01 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-30 21:54:01 +0000
commitedd03006c190712705117c6fedfef9fa6a667f9c (patch)
tree83aa809a7e3a176a32271157adba3191befe32f9 /src/char_sql/int_party.c
parent5f57279825028c335ca328631d9eae2b4d3ff516 (diff)
downloadhercules-edd03006c190712705117c6fedfef9fa6a667f9c.tar.gz
hercules-edd03006c190712705117c6fedfef9fa6a667f9c.tar.bz2
hercules-edd03006c190712705117c6fedfef9fa6a667f9c.tar.xz
hercules-edd03006c190712705117c6fedfef9fa6a667f9c.zip
- Rewrote the txt->sql converter. It now links directly to the char server files so that it should get auto-updated with any code changes in the later.
- The converter will now also convert: account-wide variables, parties, guilds, guild storage and guild castles. At this point the only two things not converted are login-server-wide account variables (##, they belong to the login converter) and homunculus (the SQL save function is messy and doesn't lends itself to be integrated with the converter the way all the other functions are). - Modified the char servers so they are compatible with the converter, the define TXT_SQL_CONVERT identifies sections unique to each char-server mode (this would had been a hella lot easier if both char servers where the same code-base instead of duplicated code <.<) - Updated the Makefiles as per the new compiling requirements for the converter. - misceffect2 will no longer cause the effect on top of the source object when it is the fake npc. - Added check so that Frost Nova doesn't hides hitting animation on targets. - Added the missing brackets around the trade logs condition check, thanks to Coltaro. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8908 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/int_party.c')
-rw-r--r--src/char_sql/int_party.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index 897a110d6..fe46ac9c6 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -14,6 +14,7 @@
#include "../common/socket.h"
#include "../common/showmsg.h"
+#ifndef TXT_SQL_CONVERT
struct party_data {
struct party party;
unsigned int min_lv, max_lv;
@@ -40,20 +41,6 @@ int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag);
#endif
-//Party Flags on what to save/delete.
-//Create a new party entry (index holds leader's info)
-#define PS_CREATE 0x01
-//Update basic party info.
-#define PS_BASIC 0x02
-//Update party's leader
-#define PS_LEADER 0x04
-//Specify new party member (index specifies which party member)
-#define PS_ADDMEMBER 0x08
-//Specify member that left (index specifies which party member)
-#define PS_DELMEMBER 0x10
-//Specify that this party must be deleted.
-#define PS_BREAK 0x20
-
//Updates party's level range and unsets even share if broken.
static int int_party_check_lv(struct party_data *p) {
int i;
@@ -114,17 +101,15 @@ static void int_party_calc_state(struct party_data *p)
}
return;
}
-
+#endif //TXT_SQL_CONVERT
// Save party to mysql
-int inter_party_tosql(struct party_data *party, int flag, int index)
+int inter_party_tosql(struct party *p, int flag, int index)
{
// 'party' ('party_id','name','exp','item','leader_id','leader_char')
char t_name[NAME_LENGTH*2]; //Required for jstrescapecpy [Skotlex]
- struct party *p;
int party_id;
- if (party == NULL || party->party.party_id == 0)
+ if (p == NULL || p->party_id == 0)
return 0;
- p = &party->party;
party_id = p->party_id;
#ifdef NOISY
@@ -132,6 +117,7 @@ int inter_party_tosql(struct party_data *party, int flag, int index)
#endif
jstrescapecpy(t_name, p->name);
+#ifndef TXT_SQL_CONVERT
if (flag&PS_BREAK) { //Break the party
// we'll skip name-checking and just reset everyone with the same party id [celest]
sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id);
@@ -148,8 +134,9 @@ int inter_party_tosql(struct party_data *party, int flag, int index)
idb_remove(party_db_, party_id);
return 1;
}
-
+#endif //TXT_SQL_CONVERT
if(flag&PS_CREATE) { //Create party
+#ifndef TXT_SQL_CONVERT
sprintf(tmp_sql, "INSERT INTO `%s` "
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
"VALUES ('%s', '%d', '%d', '%d', '%d')",
@@ -157,21 +144,29 @@ int inter_party_tosql(struct party_data *party, int flag, int index)
if (mysql_query(&mysql_handle, tmp_sql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(party); //Free party, couldn't create it.
return 0;
}
if(mysql_field_count(&mysql_handle) == 0 &&
mysql_insert_id(&mysql_handle) != 0)
party_id = p->party_id = (int)mysql_insert_id(&mysql_handle);
- else { //Failed to retrieve ID??
- aFree(party); //Free party, couldn't create it.
+ else //Failed to retrieve ID??
+ return 0;
+#else
+ //During conversion, you want to specify the id, and allow overwriting
+ //(in case someone is re-running the process.
+ sprintf(tmp_sql, "REPLACE INTO `%s` "
+ "(`party_id`, `name`, `exp`, `item`, `leader_id`, `leader_char`) "
+ "VALUES ('%d', '%s', '%d', '%d', '%d', '%d')",
+ party_db, p->party_id, t_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id);
+ if (mysql_query(&mysql_handle, tmp_sql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
return 0;
}
- //Add party to db
- int_party_calc_state(party);
- idb_put(party_db_, party_id, party);
+#endif
}
+#ifndef TXT_SQL_CONVERT
if (flag&PS_BASIC) {
//Update party info.
sprintf(tmp_sql, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
@@ -211,12 +206,12 @@ int inter_party_tosql(struct party_data *party, int flag, int index)
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
}
-
+#endif //TXT_SQL_CONVERT
if (save_log)
ShowInfo("Party Saved (%d - %s)\n", party_id, p->name);
return 1;
}
-
+#ifndef TXT_SQL_CONVERT
// Read party from mysql
struct party_data *inter_party_fromsql(int party_id)
{
@@ -365,7 +360,7 @@ int party_check_empty(struct party_data *p)
if (i < MAX_PARTY) return 0;
// If there is no member, then break the party
mapif_party_broken(p->party.party_id,0);
- inter_party_tosql(p, PS_BREAK, 0);
+ inter_party_tosql(&p->party, PS_BREAK, 0);
return 1;
}
@@ -577,11 +572,16 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
p->party.member[0].online=1;
p->party.party_id=-1;//New party.
- if (inter_party_tosql(p,PS_CREATE|PS_ADDMEMBER,0)) {
+ if (inter_party_tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) {
+ //Add party to db
+ int_party_calc_state(p);
+ idb_put(party_db_, p->party.party_id, p);
mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
mapif_party_info(fd,&p->party);
- } else //Failed to create party.
+ } else { //Failed to create party.
+ aFree(p);
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+ }
return 0;
}
@@ -627,7 +627,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member
mapif_party_memberadded(fd,party_id,member->account_id,member->char_id,0);
mapif_party_info(-1,&p->party);
- inter_party_tosql(p, PS_ADDMEMBER, i);
+ inter_party_tosql(&p->party, PS_ADDMEMBER, i);
return 0;
}
//Party full
@@ -651,7 +651,7 @@ int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int
}
p->party.item = item&0x3; //Filter out invalid values.
mapif_party_optionchanged(fd,&p->party,account_id,flag);
- inter_party_tosql(p, PS_BASIC, 0);
+ inter_party_tosql(&p->party, PS_BASIC, 0);
return 0;
}
// パーティ脱退要求
@@ -691,7 +691,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
}
//Party gets deleted on the check_empty call below.
} else {
- inter_party_tosql(p,PS_DELMEMBER,i);
+ inter_party_tosql(&p->party,PS_DELMEMBER,i);
j = p->party.member[i].lv;
if(p->party.member[i].online) p->party.count--;
memset(&p->party.member[i], 0, sizeof(struct party_member));
@@ -765,7 +765,7 @@ int mapif_parse_BreakParty(int fd,int party_id)
if(!p)
return 0;
- inter_party_tosql(p,PS_BREAK,0);
+ inter_party_tosql(&p->party,PS_BREAK,0);
mapif_party_broken(fd,party_id);
return 0;
}
@@ -798,7 +798,7 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id
p->party.member[i].char_id == char_id)
{
p->party.member[i].leader = 1;
- inter_party_tosql(p,PS_LEADER, i);
+ inter_party_tosql(&p->party,PS_LEADER, i);
}
}
return 1;
@@ -927,3 +927,4 @@ int inter_party_CharOffline(int char_id, int party_id) {
idb_remove(party_db_, party_id);
return 1;
}
+#endif //TXT_SQL_CONVERT