summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-08 15:18:32 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-08 15:18:32 -0600
commitc8da743b969b251bab107125d4af82ec7f4e376c (patch)
tree6d499634d8dcd49d80ae869cb28cca58893b1160 /src/map/itemdb.c
parent23c6c0e2c8b10bbecf1e673723914618170ac551 (diff)
downloadtmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.gz
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.bz2
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.tar.xz
tmwa-c8da743b969b251bab107125d4af82ec7f4e376c.zip
Strip some more out
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c201
1 files changed, 4 insertions, 197 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 7b3f157..499b776 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -33,9 +33,6 @@ static int blue_box_default=0,violet_box_default=0,card_album_default=0,gift_box
static void itemdb_read(void);
static int itemdb_readdb(void);
-#ifndef TXT_ONLY
-static int itemdb_read_sqldb(void);
-#endif /* not TXT_ONLY */
static int itemdb_read_randomitem();
static int itemdb_read_itemavail(void);
static int itemdb_read_itemnametable(void);
@@ -266,33 +263,6 @@ static int itemdb_read_itemslottable(void)
return 0;
}
-#ifndef TXT_ONLY
-/*====================================
- * Removed item_value_db, don't re-add
- *------------------------------------
- */
-static void itemdb_read(void)
-{
- itemdb_read_itemslottable();
-
- if (db_use_sqldbs)
- {
- itemdb_read_sqldb();
- }
- else
- {
- itemdb_readdb();
- }
-
- itemdb_read_randomitem();
- itemdb_read_itemavail();
- itemdb_read_noequip();
-
- if (!battle_config.item_name_override_grffile)
- itemdb_read_itemnametable();
-}
-
-#endif /* not TXT_ONLY */
/*==========================================
* アイテムデータベースの読み込み
*------------------------------------------
@@ -551,7 +521,7 @@ static int itemdb_read_itemnametable(void)
return 0;
}
-#ifdef TXT_ONLY
+
/*==========================================
* カードイラストのリソース名前テーブルを読み込む
*------------------------------------------
@@ -586,7 +556,7 @@ static int itemdb_read_cardillustnametable(void)
return 0;
}
-#endif /* TXT_ONLY */
+
/*==========================================
* 装備制限ファイル読み出し
*------------------------------------------
@@ -629,170 +599,7 @@ static int itemdb_read_noequip(void)
printf("read db/item_noequip.txt done (count=%d)\n",ln);
return 0;
}
-#ifndef TXT_ONLY
-
-/*======================================
-* SQL
-*===================================
-*/
-static int itemdb_read_sqldb(void)
-{
- unsigned short nameid;
- struct item_data *id;
- char script[65535 + 2 + 1]; // Maximum length of MySQL TEXT type (65535) + 2 bytes for curly brackets + 1 byte for terminator
-
- // ----------
-
- sprintf(tmp_sql, "SELECT * FROM `%s`", item_db_db);
-
- // Execute the query; if the query execution succeeded...
- if (mysql_query(&mmysql_handle, tmp_sql) == 0)
- {
- sql_res = mysql_store_result(&mmysql_handle);
-
- // If the storage of the query result succeeded...
- if (sql_res)
- {
- // Parse each row in the query result into sql_row
- while ((sql_row = mysql_fetch_row(sql_res)))
- {
- /* +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+---------------+-----------------+--------------+-------------+------+------------+--------------+
- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
- +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+---------------+-----------------+--------------+-------------+------+------------+--------------+
- | id | name_english | name_japanese | type | price_buy | price_sell | weight | attack | defence | range | slots | equip_jobs | equip_genders | equip_locations | weapon_level | equip_level | view | script_use | script_equip |
- +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+---------------+-----------------+--------------+-------------+------+------------+--------------+ */
-
- nameid = atoi(sql_row[0]);
-
- // If the identifier is not within the valid range, process the next row
- if (nameid == 0 || nameid >= 20000)
- {
- continue;
- }
-
- // Insert a new row into the item database
-
- /*id = calloc(sizeof(struct item_data), 1);
-
- if (id == NULL)
- {
- printf("out of memory : itemdb_read_sqldb\n");
- exit(1);
- }
-
- memset(id, 0, sizeof(struct item_data));
- numdb_insert(item_db, (int) nameid, id);*/
-
- // ----------
- id=itemdb_search(nameid);
-
- memcpy(id->name, sql_row[1], 25);
- memcpy(id->jname, sql_row[2], 25);
-
- id->type = atoi(sql_row[3]);
-
- // If price_buy is not NULL and price_sell is not NULL...
- if ((sql_row[4] != NULL) && (sql_row[5] != NULL))
- {
- id->value_buy = atoi(sql_row[4]);
- id->value_sell = atoi(sql_row[5]);
- }
- // If price_buy is not NULL and price_sell is NULL...
- else if ((sql_row[4] != NULL) && (sql_row[5] == NULL))
- {
- id->value_buy = atoi(sql_row[4]);
- id->value_sell = atoi(sql_row[4]) / 2;
- }
- // If price_buy is NULL and price_sell is not NULL...
- else if ((sql_row[4] == NULL) && (sql_row[5] != NULL))
- {
- id->value_buy = atoi(sql_row[5]) * 2;
- id->value_sell = atoi(sql_row[5]);
- }
- // If price_buy is NULL and price_sell is NULL...
- if ((sql_row[4] == NULL) && (sql_row[5] == NULL))
- {
- id->value_buy = 0;
- id->value_sell = 0;
- }
-
- id->weight = atoi(sql_row[6]);
-
- id->atk = (sql_row[7] != NULL) ? atoi(sql_row[7]) : 0;
- id->def = (sql_row[8] != NULL) ? atoi(sql_row[8]) : 0;
- id->range = (sql_row[9] != NULL) ? atoi(sql_row[9]) : 0;
- id->slot = (sql_row[10] != NULL) ? atoi(sql_row[10]) : 0;
- id->class = (sql_row[11] != NULL) ? atoi(sql_row[11]) : 0;
- id->sex = (sql_row[12] != NULL) ? atoi(sql_row[12]) : 0;
- id->equip = (sql_row[13] != NULL) ? atoi(sql_row[13]) : 0;
- id->wlv = (sql_row[14] != NULL) ? atoi(sql_row[14]) : 0;
- id->elv = (sql_row[15] != NULL) ? atoi(sql_row[15]) : 0;
- id->look = (sql_row[16] != NULL) ? atoi(sql_row[16]) : 0;
-
- id->view_id = 0;
-
- // ----------
-
- if (sql_row[17] != NULL)
- {
- if (sql_row[17][0] == '{')
- id->use_script = parse_script(sql_row[17], 0);
- else {
- sprintf(script, "{%s}", sql_row[17]);
- id->use_script = parse_script(script, 0);
- }
- }
- else
- {
- id->use_script = NULL;
- }
-
- if (sql_row[18] != NULL)
- {
- if (sql_row[18][0] == '{')
- id->equip_script = parse_script(sql_row[18], 0);
- else {
- sprintf(script, "{%s}", sql_row[18]);
- id->equip_script = parse_script(script, 0);
- }
- }
- else
- {
- id->equip_script = NULL;
- }
-
- // ----------
-
- id->flag.available = 1;
- id->flag.value_notdc = 0;
- id->flag.value_notoc = 0;
- }
-
- // If the retrieval failed, output an error
- if (mysql_errno(&mmysql_handle))
- {
- printf("Database server error (retrieving rows from %s): %s\n", item_db_db, mysql_error(&mmysql_handle));
- }
-
- printf("read %s done (count = %lu)\n", item_db_db, (unsigned long) mysql_num_rows(sql_res));
- }
- else
- {
- printf("MySQL error (storing query result for %s): %s\n", item_db_db, mysql_error(&mmysql_handle));
- }
-
- // Free the query result
- mysql_free_result(sql_res);
- }
- else
- {
- printf("Database server error (executing query for %s): %s\n", item_db_db, mysql_error(&mmysql_handle));
- }
-
- return 0;
-}
-#endif /* not TXT_ONLY */
/*==========================================
*
*------------------------------------------
@@ -850,7 +657,7 @@ void itemdebugtxt()
fclose(dfp);
}
*/
-#ifdef TXT_ONLY
+
/*====================================
* Removed item_value_db, don't re-add
*------------------------------------
@@ -866,7 +673,7 @@ static void itemdb_read(void)
if (!battle_config.item_name_override_grffile)
itemdb_read_itemnametable();
}
-#endif /* TXT_ONLY */
+
/*==========================================
*
*------------------------------------------