summaryrefslogtreecommitdiff
path: root/src/char/int_party.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/int_party.c')
-rw-r--r--src/char/int_party.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 269a64a8a..c86ff8c44 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -116,15 +116,15 @@ int inter_party_tosql(struct party *p, int flag, int index)
#ifdef NOISY
ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name);
#endif
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
if( flag & PS_BREAK )
{// Break the party
// we'll skip name-checking and just reset everyone with the same party id [celest]
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Remove from memory
idb_remove(inter_party->db, party_id);
return 1;
@@ -132,43 +132,43 @@ int inter_party_tosql(struct party *p, int flag, int index)
if( flag & PS_CREATE )
{// Create party
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
"VALUES ('%s', '%d', '%d', '%d', '%d')",
party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- party_id = p->party_id = (int)SQL->LastInsertId(sql_handle);
+ party_id = p->party_id = (int)SQL->LastInsertId(inter->sql_handle);
}
if( flag & PS_BASIC )
{// Update party info.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
party_db, esc_name, p->exp, p->item, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_LEADER )
{// Update leader
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_ADDMEMBER )
{// Add one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_DELMEMBER )
{// Remove one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( save_log )
@@ -201,42 +201,42 @@ struct party_data *inter_party_fromsql(int party_id)
p = inter_party->pt;
memset(p, 0, sizeof(struct party_data));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return NULL;
p->party.party_id = party_id;
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); p->party.item = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); leader_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); leader_char = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
// Load members
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
m = &p->party.member[i];
- SQL->GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
- SQL->GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); m->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); m->lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); m->class_ = atoi(data);
m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name);
@@ -261,9 +261,9 @@ int inter_party_sql_init(void)
/* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
ShowStatus("cleaning party table...\n");
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
*/
return 0;
}
@@ -282,14 +282,14 @@ struct party_data* inter_party_search_partyname(const char *const str)
char* data;
struct party_data* p = NULL;
- SQL->EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
p = inter_party->fromsql(atoi(data));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return p;
}
@@ -587,8 +587,8 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
p = inter_party->fromsql(party_id);
if( p == NULL )
{// Party does not exists?
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -772,18 +772,18 @@ int inter_party_CharOnline(int char_id, int party_id)
{// Get party_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...
@@ -818,18 +818,18 @@ int inter_party_CharOffline(int char_id, int party_id) {
{// Get guild_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...