summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/itemdb.c71
-rw-r--r--src/map/map.h8
-rw-r--r--src/map/npc.c11
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/script.c27
5 files changed, 35 insertions, 84 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 404d8514f..c81e177e1 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -9,11 +9,11 @@
#include "../common/malloc.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
-#include "map.h"
-#include "battle.h"
#include "itemdb.h"
-#include "script.h"
-#include "pc.h"
+#include "map.h"
+#include "battle.h" // struct battle_config
+#include "script.h" // item script processing
+#include "pc.h" // W_MUSICAL, W_WHIP
static struct dbt* item_db;
@@ -103,19 +103,18 @@ int itemdb_searchrandomid(int group)
}
/*==========================================
- * Calculates total item-group related bonuses for the given item. [Skotlex]
- *------------------------------------------
- */
-int itemdb_group_bonus(struct map_session_data *sd, int itemid)
+ * Calculates total item-group related bonuses for the given item
+ *------------------------------------------*/
+int itemdb_group_bonus(const int itemgrouphealrate[MAX_ITEMGROUP], int itemid)
{
int bonus = 0, i, j;
for (i=0; i < MAX_ITEMGROUP; i++) {
- if (!sd->itemgrouphealrate[i])
+ if (itemgrouphealrate[i])
continue;
for (j=0; j < itemgroup_db[i].qty; j++) {
if (itemgroup_db[i].nameid[j] == itemid)
{
- bonus += sd->itemgrouphealrate[i];
+ bonus += itemgrouphealrate[i];
break;
}
}
@@ -447,8 +446,7 @@ static int itemdb_read_itemavail (void)
/*==========================================
* read item group data
- *------------------------------------------
- */
+ *------------------------------------------*/
static void itemdb_read_itemgroup_sub(const char* filename)
{
FILE *fp;
@@ -498,7 +496,7 @@ static void itemdb_read_itemgroup_sub(const char* filename)
continue;
}
k = atoi(str[2]);
- if (itemgroup_db[groupid].qty+k > MAX_RANDITEM) {
+ if (itemgroup_db[groupid].qty+k >= MAX_RANDITEM) {
ShowWarning("itemdb_read_itemgroup: Group %d is full (%d entries) in %s:%d\n", groupid, MAX_RANDITEM, filename, ln);
continue;
}
@@ -512,52 +510,11 @@ static void itemdb_read_itemgroup_sub(const char* filename)
static void itemdb_read_itemgroup(void)
{
char path[256];
- int i;
- const char* groups[] = {
- "Blue Box",
- "Violet Box",
- "Card Album",
- "Gift Box",
- "Scroll Box",
- "Finding Ore",
- "Cookie Bag",
- "Potion",
- "Herbs",
- "Fruits",
- "Meat",
- "Candy",
- "Juice",
- "Fish",
- "Boxes",
- "Gemstone",
- "Jellopy",
- "Ore",
- "Food",
- "Recovery",
- "Minerals",
- "Taming",
- "Scrolls",
- "Quivers",
- "Masks",
- "Accesory",
- "Jewels",
- "Gift Box 1",
- "Gift Box 2",
- "Gift Box 3",
- "Gift Box 4",
- "Egg Boy",
- "Egg Girl",
- "Gift Box China",
- "Lotto Box",
- };
- memset(&itemgroup_db, 0, sizeof(itemgroup_db));
snprintf(path, 255, "%s/item_group_db.txt", db_path);
+
+ memset(&itemgroup_db, 0, sizeof(itemgroup_db));
itemdb_read_itemgroup_sub(path);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","item_group_db.txt");
- if (battle_config.etc_log) {
- for (i = 1; i < MAX_ITEMGROUP; i++)
- ShowInfo("Group %s: %d entries.\n", groups[i-1], itemgroup_db[i].qty);
- }
+ ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", "item_group_db.txt");
return;
}
diff --git a/src/map/map.h b/src/map/map.h
index 14fbf6e31..a6f0cf614 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -9,6 +9,8 @@
#include "../common/mapindex.h"
#include "../common/db.h"
+#include "itemdb.h" // MAX_ITEMGROUP
+
//Uncomment to enable the Cell Stack Limit mod.
//It's only config is the battle_config cell_stack_limit.
//Only chars affected are those defined in BL_CHAR (mobs and players currently)
@@ -56,8 +58,6 @@
#define MOBID_EMPERIUM 1288
#define MAX_PC_BONUS 10
-//Designed for search functions, species max number of matches to display.
-#define MAX_SEARCH 5
#define MAX_DUEL 1024
#define map_id2index(id) map[(id)].index
@@ -229,10 +229,6 @@ enum {
ELE_MAX
};
-//The onlu item group required by the code to be known.
-#define IG_FINDINGORE 6
-#define MAX_ITEMGROUP 40
-
enum {
ATF_SELF=0x01,
ATF_TARGET=0x02,
diff --git a/src/map/npc.c b/src/map/npc.c
index 9cb53327a..f4be64e16 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -90,12 +90,12 @@ int npc_enable_sub( struct block_list *bl, va_list ap )
{
struct map_session_data *sd;
struct npc_data *nd;
- //char *name=(char *)aCallocA(50,sizeof(char)); // fixed [Shinomori]
nullpo_retr(0, bl);
nullpo_retr(0, ap);
nullpo_retr(0, nd=va_arg(ap,struct npc_data *));
- if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){
+ if(bl->type == BL_PC && (sd=(struct map_session_data *)bl))
+ {
char name[50]; // need 24 + 9 for the "::OnTouch"
if (nd->sc.option&OPTION_INVISIBLE) // 無効化されている
@@ -2136,7 +2136,8 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
//-----------------------------------------
// イベント用ラベルデータのエクスポート
- for (i = 0; i < nd->u.scr.label_list_num; i++){
+ for (i = 0; i < nd->u.scr.label_list_num; i++)
+ {
char *lname = nd->u.scr.label_list[i].name;
int pos = nd->u.scr.label_list[i].pos;
@@ -2149,11 +2150,9 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
exit(1);
} else {
struct event_data *ev;
- unsigned char buf[51];
- // 51 comes from: 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
+ unsigned char buf[50+1]; // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
sprintf(buf,"%s::%s",nd->exname,lname);
- // remember the label is max 50 chars + eos; see the strdb_init below
// generate the data and insert it
ev=(struct event_data *)aMalloc(sizeof(struct event_data));
ev->nd=nd;
diff --git a/src/map/npc.h b/src/map/npc.h
index f4c092dc0..1d5a43367 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -37,7 +37,7 @@ struct view_data* npc_get_viewdata(int class_);
int npc_chat_sub(struct block_list *bl, va_list ap);
int npc_event_dequeue(struct map_session_data *sd);
int npc_event_timer(int tid,unsigned int tick,int id,int data);
-int npc_event(struct map_session_data *sd,const unsigned char *npcname,int);
+int npc_event(struct map_session_data *sd, const unsigned char *eventname, int mob_kill);
int npc_timer_event(const unsigned char *eventname); // Added by RoVeRT
int npc_command(struct map_session_data* sd, const char* npcname, const char* command);
int npc_touch_areanpc(struct map_session_data *,int,int,int);
diff --git a/src/map/script.c b/src/map/script.c
index 513d3be6f..b0f582b58 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10134,33 +10134,32 @@ BUILDIN_FUNC(clearitem)
}
/*==========================================
- Disguise Player (returns Mob/NPC ID if success, 0 on fail) [Lupus]
- *------------------------------------------
- */
+ * Disguise Player (returns Mob/NPC ID if success, 0 on fail)
+ *------------------------------------------*/
BUILDIN_FUNC(disguise)
{
- struct map_session_data *sd=script_rid2sd(st);
int id;
+ struct map_session_data* sd = script_rid2sd(st);
+ if (sd == NULL) return 0;
- id = script_getnum(st,2);
+ id = script_getnum(st,2);
- if (!mobdb_checkid(id) && !npcdb_checkid(id)) {
+ if (mobdb_checkid(id) || npcdb_checkid(id)) {
+ pc_disguise(sd, id);
+ script_pushint(st,id);
+ } else
script_pushint(st,0);
- return 0;
- }
- pc_disguise(sd, id);
- script_pushint(st,id);
return 0;
}
/*==========================================
- Undisguise Player (returns 1 if success, 0 on fail) [Lupus]
- *------------------------------------------
- */
+ * Undisguise Player (returns 1 if success, 0 on fail)
+ *------------------------------------------*/
BUILDIN_FUNC(undisguise)
{
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data* sd = script_rid2sd(st);
+ if (sd == NULL) return 0;
if (sd->disguise) {
pc_disguise(sd, 0);