summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c6
-rw-r--r--src/map/chrif.c20
-rw-r--r--src/map/chrif.h2
-rw-r--r--src/map/clif.c17
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/itemdb.c161
-rw-r--r--src/map/itemdb.h4
-rw-r--r--src/map/packets.h2
8 files changed, 140 insertions, 73 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 32e450bc0..cd8c36b69 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -4696,11 +4696,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
ATK_RATE(i);
- #ifdef RENEWAL
- if( skill_id && (wd.damage+wd.damage2) ){
- RE_SKILL_REDUCTION();
- }
- #endif
+
if( sd ) {
if (skill_id && (i = pc->skillatk_bonus(sd, skill_id)))
ATK_ADDRATE(i);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 56572d492..5927e31bf 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -966,21 +966,21 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
}
/*==========================================
- * Disconnection of a player (account has been banned of has a status, from login-server) by [Yor]
+ * Disconnection of a player (account or char has been banned of has a status, from login or char server) by [Yor]
*------------------------------------------*/
-int chrif_accountban(int fd) {
- int acc;
+int chrif_idbanned(int fd) {
+ int id;
struct map_session_data *sd;
- acc = RFIFOL(fd,2);
+ id = RFIFOL(fd,2);
if ( battle_config.etc_log )
- ShowNotice("chrif_accountban %d.\n", acc);
+ ShowNotice("chrif_idbanned %d.\n", id);
- sd = map->id2sd(acc);
+ sd = ( RFIFOB(fd,6) == 2 ) ? map->charid2sd(id) : map->id2sd(id);
- if ( acc < 0 || sd == NULL ) {
- ShowError("chrif_accountban failed - player not online.\n");
+ if ( id < 0 || sd == NULL ) {
+ /* player not online or unknown id, either way no error is necessary (since if you try to ban a offline char it still works) */
return 0;
}
@@ -1453,7 +1453,7 @@ int chrif_parse(int fd) {
case 0x2b0d: chrif->changedsex(fd); break;
case 0x2b0f: chrif->char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break;
case 0x2b12: chrif->divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break;
- case 0x2b14: chrif->accountban(fd); break;
+ case 0x2b14: chrif->idbanned(fd); break;
case 0x2b1b: chrif->recvfamelist(fd); break;
case 0x2b1d: chrif->load_scdata(fd); break;
case 0x2b1e: chrif->update_ip(fd); break;
@@ -1748,7 +1748,7 @@ void chrif_defaults(void) {
chrif->changemapserverack = chrif_changemapserverack;
chrif->changedsex = chrif_changedsex;
chrif->divorceack = chrif_divorceack;
- chrif->accountban = chrif_accountban;
+ chrif->idbanned = chrif_idbanned;
chrif->recvfamelist = chrif_recvfamelist;
chrif->load_scdata = chrif_load_scdata;
chrif->update_ip = chrif_update_ip;
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 56aa569a3..b69d34210 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -127,7 +127,7 @@ struct chrif_interface {
int (*changemapserverack) (int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port);
int (*changedsex) (int fd);
int (*divorceack) (int char_id, int partner_id);
- int (*accountban) (int fd);
+ int (*idbanned) (int fd);
int (*recvfamelist) (int fd);
int (*load_scdata) (int fd);
void (*update_ip) (int fd);
diff --git a/src/map/clif.c b/src/map/clif.c
index dc3b00e6a..84976d67c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -17966,6 +17966,22 @@ void clif_notify_bounditem(struct map_session_data *sd, unsigned short index) {
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
+/* (GM) right click -> 'remove all equipment' */
+void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) {
+ struct map_session_data *tsd = map->id2sd(RFIFOL(fd,2));
+ int i;
+
+ /* TODO maybe this could be a new permission? using gm level in the meantime */
+ if( !tsd || pc->get_group_level(tsd) >= pc->get_group_level(sd) )
+ return;
+
+ for( i = 0; i < EQI_MAX; i++ ) {
+ if( tsd->equip_index[ i ] >= 0 )
+ pc->unequipitem( tsd , tsd->equip_index[ i ] , 2 );
+ }
+}
+
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -18914,6 +18930,7 @@ void clif_defaults(void) {
clif->pGMRc = clif_parse_GMRc;
clif->pGMReqAccountName = clif_parse_GMReqAccountName;
clif->pGMChangeMapType = clif_parse_GMChangeMapType;
+ clif->pGMFullStrip = clif_parse_GMFullStrip;
clif->pPMIgnore = clif_parse_PMIgnore;
clif->pPMIgnoreAll = clif_parse_PMIgnoreAll;
clif->pPMIgnoreList = clif_parse_PMIgnoreList;
diff --git a/src/map/clif.h b/src/map/clif.h
index 043f7dd3a..88f3383d1 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1162,6 +1162,7 @@ struct clif_interface {
void (*pGMRc) (int fd, struct map_session_data* sd);
void (*pGMReqAccountName) (int fd, struct map_session_data *sd);
void (*pGMChangeMapType) (int fd, struct map_session_data *sd);
+ void (*pGMFullStrip) (int fd, struct map_session_data *sd);
void (*pPMIgnore) (int fd, struct map_session_data* sd);
void (*pPMIgnoreAll) (int fd, struct map_session_data *sd);
void (*pPMIgnoreList) (int fd,struct map_session_data *sd);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 51986fcf6..9c3ff4138 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1532,6 +1532,24 @@ int itemdb_gendercheck(struct item_data *id)
return (battle_config.ignore_items_gender) ? 2 : id->sex;
}
+
+/**
+ * Validates an item DB entry and inserts it into the database.
+ * This function is called after preparing the item entry data, and it takes
+ * care of inserting it and cleaning up any remainders of the previous one.
+ *
+ * @param *entry Pointer to the new item_data entry. Ownership is NOT taken,
+ * but the content is modified to reflect the validation.
+ * @param n Ordinal number of the entry, to be displayed in case of
+ * validation errors.
+ * @param *source Source of the entry (table or file name), to be displayed in
+ * case of validation errors.
+ * @return Nameid of the validated entry, or 0 in case of failure.
+ *
+ * Note: This is safe to call if the new entry is a copy of the old one (i.e.
+ * item_db2 inheritance), as it will make sure not to free any scripts still in
+ * use in the new entry.
+ */
int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
struct item_data *item;
@@ -1594,7 +1612,7 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
if( !entry->elvmax )
entry->elvmax = MAX_LEVEL;
- else if( entry->elvmax > entry->elv )
+ else if( entry->elvmax < entry->elv )
entry->elvmax = entry->elv;
if( entry->type != IT_ARMOR && entry->type != IT_WEAPON && !entry->flag.no_refine )
@@ -1607,15 +1625,15 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
// Validated. Finally insert it
item = itemdb->load(entry->nameid);
- if (item->script) {
+ if (item->script && item->script != entry->script) { // Don't free if it's inheriting the same script
script->free_code(item->script);
item->script = NULL;
}
- if (item->equip_script) {
+ if (item->equip_script && item->equip_script != entry->equip_script) { // Don't free if it's inheriting the same script
script->free_code(item->equip_script);
item->equip_script = NULL;
}
- if (item->unequip_script) {
+ if (item->unequip_script && item->unequip_script != entry->unequip_script) { // Don't free if it's inheriting the same script
script->free_code(item->unequip_script);
item->unequip_script = NULL;
}
@@ -1623,9 +1641,20 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
*item = *entry;
return item->nameid;
}
-/*==========================================
- * processes one itemdb entry
- *------------------------------------------*/
+
+/**
+ * Processes one itemdb entry from the sql backend, loading and inserting it
+ * into the item database.
+ *
+ * @param *handle MySQL connection handle. It is expected to have data
+ * available (i.e. already queried) and it won't be freed (it
+ * is care of the caller to do so)
+ * @param n Ordinal number of the entry, to be displayed in case of
+ * validation errors.
+ * @param *source Source of the entry (table name), to be displayed in case of
+ * validation errors.
+ * @return Nameid of the validated entry, or 0 in case of failure.
+ */
int itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) {
struct item_data id = { 0 };
char *data = NULL;
@@ -1686,6 +1715,19 @@ int itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) {
return itemdb->validate_entry(&id, n, source);
}
+/**
+ * Processes one itemdb entry from the sql backend, loading and inserting it
+ * into the item database.
+ *
+ * @param *it Libconfig setting entry. It is expected to be valid and it
+ * won't be freed (it is care of the caller to do so if
+ * necessary)
+ * @param n Ordinal number of the entry, to be displayed in case of
+ * validation errors.
+ * @param *source Source of the entry (file name), to be displayed in case of
+ * validation errors.
+ * @return Nameid of the validated entry, or 0 in case of failure.
+ */
int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source) {
struct item_data id = { 0 };
config_setting_t *t = NULL;
@@ -1845,11 +1887,14 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
return itemdb->validate_entry(&id, n, source);
}
-/*==========================================
- * Reading item from item db
- * item_db2 overwriting item_db
- *------------------------------------------*/
-int itemdb_readdb(const char *filename) {
+/**
+ * Reads from a libconfig-formatted itemdb file and inserts the found entries into the
+ * item database, overwriting duplicate ones (i.e. item_db2 overriding item_db.)
+ *
+ * @param *filename File name, relative to the database path.
+ * @return The number of found entries.
+ */
+int itemdb_readdb_libconfig(const char *filename) {
bool duplicate[MAX_ITEMDB];
config_t item_db_conf;
config_setting_t *itdb, *it;
@@ -1880,44 +1925,43 @@ int itemdb_readdb(const char *filename) {
config_destroy(&item_db_conf);
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
- return 0;
+ return count;
}
-/*======================================
- * item_db table reading
- *======================================*/
-int itemdb_read_sqldb(void) {
- const char* item_db_name[] = {
-#ifdef RENEWAL
- map->item_db_re_db,
-#else // not RENEWAL
- map->item_db_db,
-#endif // RENEWAL
- map->item_db2_db };
- int fi;
-
- for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) {
- int i = 0;
- uint32 count = 0;
+
+/**
+ * Reads from a sql itemdb table and inserts the found entries into the item
+ * database, overwriting duplicate ones (i.e. item_db2 overriding item_db.)
+ *
+ * @param *tablename Table name to query.
+ * @return The number of found entries.
+ */
+int itemdb_readdb_sql(const char *tablename) {
+ int i = 0, count = 0;
- // retrieve all rows from the item database
- if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) {
- Sql_ShowDebug(map->mysql_handle);
- continue;
- }
+ // retrieve all rows from the item database
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT `id`, `name_english`, `name_japanese`, `type`,"
+ " `price_buy`, `price_sell`, `weight`, `atk`,"
+ " `matk`, `defence`, `range`, `slots`,"
+ " `equip_jobs`, `equip_upper`, `equip_genders`, `equip_locations`,"
+ " `weapon_level`, `equip_level_min`, `equip_level_max`, `refineable`,"
+ " `view`, `bindonequip`, `script`, `equip_script`, `unequip_script`"
+ "FROM `%s`", tablename) ) {
+ Sql_ShowDebug(map->mysql_handle);
+ return 0;
+ }
- // process rows one by one
- while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) {
- if( itemdb->readdb_sql_sub(map->mysql_handle, i++, item_db_name[fi]) )
- count++;
- }
+ // process rows one by one
+ while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) {
+ if( itemdb->readdb_sql_sub(map->mysql_handle, i++, tablename) )
+ count++;
+ }
- // free the query result
- SQL->FreeResult(map->mysql_handle);
+ // free the query result
+ SQL->FreeResult(map->mysql_handle);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]);
- }
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, tablename);
- return 0;
+ return count;
}
/*==========================================
@@ -1963,23 +2007,32 @@ int itemdb_uid_load() {
return 0;
}
-/*====================================
- * read all item-related databases
- *------------------------------------*/
+/**
+ * Reads all item-related databases.
+ */
void itemdb_read(bool minimal) {
int i;
DBData prev;
- if (map->db_use_sql_item_db)
- itemdb->read_sqldb();
- else {
+ if (map->db_use_sql_item_db) {
+ const char* item_db_name[] = {
+#ifdef RENEWAL
+ map->item_db_re_db,
+#else // not RENEWAL
+ map->item_db_db,
+#endif // RENEWAL
+ map->item_db2_db
+ };
+ for(i = 0; i < ARRAYLENGTH(item_db_name); i++)
+ itemdb->readdb_sql(item_db_name[i]);
+ } else {
const char* filename[] = {
DBPATH"item_db.conf",
"item_db2.conf",
};
for(i = 0; i < ARRAYLENGTH(filename); i++)
- itemdb->readdb(filename[i]);
+ itemdb->readdb_libconfig(filename[i]);
}
for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) {
@@ -2001,7 +2054,7 @@ void itemdb_read(bool minimal) {
sv->readdb(map->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail);
sv->readdb(map->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade);
- sv->readdb(map->db_path, DBPATH"item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay);
+ sv->readdb(map->db_path, DBPATH"item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay);
sv->readdb(map->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack);
sv->readdb(map->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore);
sv->readdb(map->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse);
@@ -2285,8 +2338,8 @@ void itemdb_defaults(void) {
itemdb->validate_entry = itemdb_validate_entry;
itemdb->readdb_sql_sub = itemdb_readdb_sql_sub;
itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub;
- itemdb->readdb = itemdb_readdb;
- itemdb->read_sqldb = itemdb_read_sqldb;
+ itemdb->readdb_libconfig = itemdb_readdb_libconfig;
+ itemdb->readdb_sql = itemdb_readdb_sql;
itemdb->unique_id = itemdb_unique_id;
itemdb->uid_load = itemdb_uid_load;
itemdb->read = itemdb_read;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 092db52d7..3f31c79d4 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -350,8 +350,8 @@ struct itemdb_interface {
int (*validate_entry) (struct item_data *entry, int n, const char *source);
int (*readdb_sql_sub) (Sql *handle, int n, const char *source);
int (*readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
- int (*readdb) (const char *filename);
- int (*read_sqldb) (void);
+ int (*readdb_libconfig) (const char *filename);
+ int (*readdb_sql) (const char *tablename);
uint64 (*unique_id) (int8 flag, int64 value);
int (*uid_load) ();
void (*read) (bool minimal);
diff --git a/src/map/packets.h b/src/map/packets.h
index 55a85e182..08c73fdb0 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -1613,7 +1613,7 @@ packet(0x020d,-1);
//2009-10-27aRagexeRE
#if PACKETVER >= 20091027
- packet(0x07f5,6,clif->pGMReqAccountName,2);
+ packet(0x07f5,6,clif->pGMFullStrip,2);
packet(0x07f6,14);
#endif