partial SQL Castles Saving (doesn't clear GuildID when you abandon a castle yet)

added 2 fixex by Pow (max positions, max guild members)

fixed Moving HP quest (added missing delitem)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1199 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Lupus 2005-03-02 23:19:46 +00:00
parent 73879f7131
commit 58433b45e4
5 changed files with 79 additions and 48 deletions

View File

@ -1,6 +1,8 @@
Date Added
03/02
* Fixed SQL Guild Castle Saving (partial, yet it doesn't clear GuildID when you abandon a castle) [Lupus]
+ added 2 fixes by POW (Mac Guild Position fix, Max Guild Members fix)
* Fixed Emotion Flood (by Yor) [Lupus]
* SQL: Fixed temporary ban. Now banned players can enter the server when the ban time is over. [Lupus]
It wasn't working because STATE hasn't been cleared properly.

View File

@ -288,6 +288,11 @@
//Supernovice's Guardian Angel
//----------------------------
540: guardian angel, can you hear my voice? ^^;
541: my name is %s, and i'm a super novice~
542: please help me~ t.t
540: Guardian Angel, can you hear my voice? ^^;
541: My name is %s, and I'm a Super Novice~
542: Please help me~ t.t
//Guilds Default Ranks/Positions
543: GuildMaster
544: Newbie
545: Position %d

View File

@ -35,6 +35,9 @@ Other Ppl
Date Added
======
03/03
* Fixed Moving HP skill quest
02/28
* warps/louyang.txt: Added 2 escapes from 2 mountains 018,019 [Lupus]
Some players used to stuck there after warps

View File

@ -3,15 +3,16 @@
//===== By: ==================================================
//= kobra_k88
//===== Current Version: =====================================
//= 1.0a
//= 1.1
//===== Compatible With: =====================================
//= eAthena 7.15 +
//===== Description: =========================================
//= <Description>
//===== Additional Comments: =================================
//= Fully working
//=1.0a Now using functions found in "Global_Functions.txt" for
//= class checks.
//= 1.0a Now using functions found in "Global_Functions.txt"
//= for class checks.
//= 1.1 Added missing delitem [Lupus]
//============================================================
@ -233,6 +234,7 @@ L_Check:
mes "Haha! You have just learned HP Moving Recovery!";
delitem 713,200;
delitem 1058,1;
delitem 2312,1;
skill 144,1,0;
set MOVHPREC, 0;
next;

View File

@ -3,7 +3,6 @@
// SQL conversion by hack
//
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -362,6 +361,9 @@ struct guild * inter_guild_fromsql(int guild_id)
strncpy(g->master,sql_row[2],24);
g->guild_lv=atoi(sql_row[3]);
g->connect_member=atoi(sql_row[4]);
if (atoi(sql_row[5]) > MAX_GUILD) // Fix reduction of MAX_GUILD [PoW]
g->max_member = MAX_GUILD;
else
g->max_member = atoi(sql_row[5]);
g->average_lv=atoi(sql_row[6]);
g->exp=atoi(sql_row[7]);
@ -410,7 +412,11 @@ struct guild * inter_guild_fromsql(int guild_id)
m->exp=atoi(sql_row[8]);
m->exp_payper=atoi(sql_row[9]);
m->online=atoi(sql_row[10]);
if (atoi(sql_row[11]) >= MAX_GUILDPOSITION) // Fix reduction of MAX_GUILDPOSITION [PoW]
m->position = MAX_GUILDPOSITION - 1;
else
m->position = atoi(sql_row[11]);
strncpy(m->name,sql_row[14],24);
}
}
@ -505,7 +511,7 @@ struct guild * inter_guild_fromsql(int guild_id)
return g;
}
#if 0
#if 1
static int _set_guild_castle(void *key, void *data, va_list ap) {
int castle_id = va_arg(ap, int);
int guild_id = va_arg(ap, int);
@ -519,51 +525,64 @@ static int _set_guild_castle(void *key, void *data, va_list ap) {
}
#endif
// Save guild_castle to sql
int inter_guildcastle_tosql(struct guild_castle *gc){
int inter_guildcastle_tosql(struct guild_castle *gc)
{
struct guild_castle *gcopy;
// `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`)
if(gc->castle_id < 0 || gc->guild_id <= 0){ //fixed bug! gc->castle_id can be == 0 (for the 1st castle it's == 0) [Lupus]
return 0;
}
printf("[Guild Castle]: Save..");
sprintf(tmp_sql, "SELECT `castle_id` FROM `%s` WHERE `castle_id` = '%d'", guild_castle_db, gc->castle_id);
if(mysql_query(&mysql_handle, tmp_sql)){
//fail ://
printf(" fail, DB ERROR: %s\n", mysql_error(&mysql_handle));
if(gc == NULL || gc->castle_id < 0 ){ //gc->castle_id can be == 0 (for the 1st castle it's == 0) [Lupus]
return 0;
}
sql_res = mysql_store_result(&mysql_handle);
if(sql_res!=NULL){ //fixed [Lupus]
if(mysql_num_rows(sql_res) > 0){
//okay .. guild is existable
mysql_free_result(sql_res);
sprintf(tmp_sql, "UPDATE `%s` SET `guild_id` = '%d', `economy` = '%d', `defense` = '%d', `triggerE` = '%d', `triggerD` = '%d', `nextTime` = '%d', `payTime` = '%d', `createTime` = '%d', `visibleC` = '%d', `visibleG0` = '%d', `visibleG1` = '%d', `visibleG2` = '%d', `visibleG3` = '%d', `visibleG4` = '%d', `visibleG5` = '%d', `visibleG6` = '%d', `visibleG7` = '%d', `gHP0` = '%d', `gHP1` = '%d', `gHP2` = '%d', `gHP3` = '%d', `gHP4` = '%d', `gHP5` = '%d', `gHP6` = '%d', `gHP7` = '%d' WHERE `castle_id` = '%d'", guild_castle_db, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5,gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7, gc->castle_id);
if( gc->guild_id > 0) { //we just update the castle
printf("[Guild Castle %02i]: Save...\n",gc->castle_id);
gcopy = numdb_search(castle_db_,gc->castle_id);
if (gcopy == NULL) {
gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle));
numdb_insert(castle_db_, gc->castle_id, gcopy);
} else {
//if the castle data hasn't been changed, then we don't write it into SQL
if ((gc->guild_id == gcopy->guild_id ) && ( gc->economy == gcopy->economy ) && ( gc->defense == gcopy->defense ) && ( gc->triggerE == gcopy->triggerE ) && ( gc->triggerD == gcopy->triggerD ) && ( gc->nextTime == gcopy->nextTime ) && ( gc->payTime == gcopy->payTime ) && ( gc->createTime == gcopy->createTime ) && ( gc->visibleC == gcopy->visibleC ) && ( gc->visibleG0 == gcopy->visibleG0 ) && ( gc->visibleG1 == gcopy->visibleG1 ) && ( gc->visibleG2 == gcopy->visibleG2 ) && ( gc->visibleG3 == gcopy->visibleG3 ) && ( gc->visibleG4 == gcopy->visibleG4 ) && ( gc->visibleG5 == gcopy->visibleG5 ) && ( gc->visibleG6 == gcopy->visibleG6 ) && ( gc->visibleG7 == gcopy->visibleG7 ) && ( gc->Ghp0 == gcopy->Ghp0 ) && ( gc->Ghp1 == gcopy->Ghp1 ) && ( gc->Ghp2 == gcopy->Ghp2 ) && ( gc->Ghp3 == gcopy->Ghp3 ) && ( gc->Ghp4 == gcopy->Ghp4 ) && ( gc->Ghp5 == gcopy->Ghp5 ) && ( gc->Ghp6 == gcopy->Ghp6 ) && ( gc->Ghp7 == gcopy->Ghp7 ))
return 0;
}
printf("[Guild Castle %02i]: Save... ->SQL\n",gc->castle_id);
memcpy(gcopy, gc, sizeof(struct guild_castle));
sprintf(tmp_sql,"REPLACE INTO `%s` "
"(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`,"
"`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`,"
"`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)"
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime,
gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5,
gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7);
//printf(" %s\n",tmp_sql);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf(" fail, DB ERROR: %s\n", mysql_error(&mysql_handle));
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
return 0;
}else{
printf(" done(U). (Castle: %d)\n", gc->castle_id);
return 1;
}
} else {
//not exists insert ..
sprintf(tmp_sql,"INSERT INTO `%s` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`, `gHP0`, `gHP1`, `gHP2`, `gHP3`, `gHP4`, `gHP5`, `gHP6`, `gHP7`) VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5, gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7);
sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='-1' WHERE `castle_id`='%d'",guild_db, gc->castle_id);
//printf(" %s\n",tmp_sql);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf(" fail, DB ERROR: %s\n", mysql_error(&mysql_handle));
return 0;
}else{
printf(" done(I). (Castle: %d)\n", gc->castle_id);
return 1;
}
}
}else{
printf(" fail, DB ERROR: %s\n", mysql_error(&mysql_handle));
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
return 0;
}
sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='%d' WHERE `guild_id`='%d'",guild_db, gc->castle_id,gc->guild_id);
//printf(" %s\n",tmp_sql);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
return 0;
}
}
db_foreach(guild_db_, _set_guild_castle, gc->castle_id,gc->guild_id);
return 0;
}
// Read guild_castle from sql
int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc)
{