From 045c1a44df08c1472f5a95742628a2765c1be9d1 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 24 Jun 2013 16:23:46 -0300 Subject: Follow up fcba8a2161a392369db99ab9a516a24470c54796 Fixed "random" item package rates, special thanks to Beret. Also, added the missing (+130) item package calls (special thanks to Streusel!) Signed-off-by: shennetsind --- src/map/itemdb.c | 18 ++++++++++++++---- src/plugins/db2sql.c | 7 ++++++- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 0ff991bad..6fd8b166c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -199,7 +199,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa entry = &package->random_list[rnd()%package->random_qty]; - for( i = 0; i < package->random_qty; i++ ) { + while( 1 ) { if( rnd()%10000 >= entry->rate ) { entry = entry->next; continue; @@ -625,7 +625,7 @@ void itemdb_read_groups(void) { const char *itname; int i = 0, count = 0, c; unsigned int *gsize = NULL; - + if (conf_read_file(&item_group_conf, config_filename)) { ShowError("can't read %s\n", config_filename); return; @@ -760,7 +760,7 @@ void itemdb_read_packages(void) { int r = 0, m = 0; data->package = &itemdb->packages[count]; - + itemdb->packages[count].id = data->nameid; itemdb->packages[count].random_list = NULL; itemdb->packages[count].must_items = NULL; @@ -811,12 +811,16 @@ void itemdb_read_packages(void) { } else { if( prev ) prev->next = &itemdb->packages[count].random_list[r]; + itemdb->packages[count].random_list[r].id = data ? data->nameid : 0; itemdb->packages[count].random_list[r].qty = icount; + itemdb->packages[count].random_list[r].rate = rate; itemdb->packages[count].random_list[r].hours = expire; itemdb->packages[count].random_list[r].announce = announce == true ? 1 : 0; itemdb->packages[count].random_list[r].named = named == true ? 1 : 0; + prev = &itemdb->packages[count].random_list[r]; + r++; } @@ -825,6 +829,12 @@ void itemdb_read_packages(void) { if( prev ) prev->next = &itemdb->packages[count].random_list[0]; + if( itemdb->packages[count].random_qty == 1 ) { + //item packages dont stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed. + ShowWarning("itemdb_read_packages: '%s' has only 1 random option, drop rate will be 100%!\n",itemdb_name(itemdb->packages[count].id)); + itemdb->packages[count].random_list[0].rate = 10000; + } + count++; } @@ -1625,7 +1635,6 @@ int itemdb_uid_load() { * read all item-related databases *------------------------------------*/ static void itemdb_read(void) { - if (iMap->db_use_sqldbs) itemdb_read_sqldb(); else @@ -1635,6 +1644,7 @@ static void itemdb_read(void) { itemdb->read_groups(); itemdb->read_chains(); itemdb->read_packages(); + sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail); sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index a6e1c20e6..c4d4adff1 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -17,7 +17,7 @@ HPExport struct hplugin_info pinfo = { "DB2SQL", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? - "0.2", // Plugin version + "0.3", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; @@ -98,6 +98,11 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { CPCMD(db2sql) { + if( iMap->db_use_sqldbs ) { + ShowInfo("db2sql: this should not be used with 'db_use_sqldbs' enabled, skipping...\n"); + return; + } + stmt = SQL->StmtMalloc(mysql_handle); if( stmt == NULL ) { SqlStmt_ShowDebug(stmt); -- cgit v1.2.3-70-g09d2