summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c26
-rw-r--r--src/map/magic-stmt.c26
-rw-r--r--src/map/magic.c6
-rw-r--r--src/map/map.c24
-rw-r--r--src/map/map.h12
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/pc.c44
7 files changed, 137 insertions, 3 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index e424ef9..ebc395d 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3937,6 +3937,32 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target,
skill_castend_damage_id(src,target,0,-1,tick,0);
map_freeblock_lock();
+ if (src->type == BL_PC) {
+ int weapon_index = sd->equip_index[9];
+ int weapon = 0;
+ if (sd->inventory_data[weapon_index] && sd->status.inventory[weapon_index].equip & 0x2)
+ weapon = sd->inventory_data[weapon_index]->nameid;
+
+ MAP_LOG("PC%d %d:%d,%d WPNDMG %s%d %d FOR %d WPN %d",
+ sd->status.char_id, src->m, src->x, src->y,
+ (target->type == BL_PC)? "PC" : "MOB",
+ (target->type == BL_PC)? ((struct map_session_data *) target)->status.char_id : target->id,
+ (target->type == BL_PC)? 0 : ((struct mob_data *)target)->class,
+ wd.damage+wd.damage2,
+ weapon
+ );
+ }
+
+ if (target->type == BL_PC) {
+ struct map_session_data *sd2 = (struct map_session_data *) target;
+ MAP_LOG("PC%d %d:%d,%d WPNINJURY %s%d %d FOR %d",
+ sd2->status.char_id, target->m, target->x, target->y,
+ (src->type == BL_PC)? "PC" : "MOB",
+ (src->type == BL_PC)? ((struct map_session_data *) src)->status.char_id : src->id,
+ (src->type == BL_PC)? 0 : ((struct mob_data *)src)->class,
+ wd.damage+wd.damage2);
+ }
+
battle_damage(src,target,(wd.damage+wd.damage2),0);
if(target->prev != NULL &&
(target->type != BL_PC || (target->type == BL_PC && !pc_isdead((struct map_session_data *)target) ) ) ) {
diff --git a/src/map/magic-stmt.c b/src/map/magic-stmt.c
index cba0659..55e6133 100644
--- a/src/map/magic-stmt.c
+++ b/src/map/magic-stmt.c
@@ -285,10 +285,19 @@ op_instaheal(env_t *env, int args_nr, val_t *args)
entity_t *caster = (VAR(VAR_CASTER).ty == TY_ENTITY)
? map_id2bl(VAR(VAR_CASTER).v.v_int)
: NULL;
+ entity_t *subject = ARGENTITY(0);
if (!caster)
- caster = ARGENTITY(0);
-
- battle_heal(caster, ARGENTITY(0), ARGINT(1), ARGINT(2), 0);
+ caster = subject;
+
+ if (caster->type == BL_PC && subject->type == BL_PC) {
+ character_t *caster_pc = (character_t *) caster;
+ character_t *subject_pc = (character_t *) subject;
+ MAP_LOG("PC%d %d:%d,%d SPELLHEAL-INSTA PC%d FOR %d",
+ caster_pc->status.char_id, caster->m, caster->x, caster->y,
+ subject_pc->status.char_id, ARGINT(1));
+ }
+
+ battle_heal(caster, subject, ARGINT(1), ARGINT(2), 0);
return 0;
}
@@ -696,6 +705,17 @@ op_injure(env_t *env, int args_nr, val_t *args)
// display damage first, because dealing damage may deallocate the target.
clif_damage(caster, target, gettick(),
0, 0, damage_caused, 0, 0, 0);
+
+ if (caster->type == BL_PC) {
+ character_t *caster_pc = (character_t *) caster;
+ if (target->type == BL_MOB) {
+ struct mob_data *mob = (struct mob_data *) target;
+
+ MAP_LOG("PC%d %d:%d,%d SPELLDMG MOB%d %d FOR %d",
+ caster_pc->status.char_id, caster->m, caster->x, caster->y,
+ mob->bl.id, mob->class, damage_caused);
+ }
+ }
battle_damage(caster, target, damage_caused, mp_damage);
return 0;
diff --git a/src/map/magic.c b/src/map/magic.c
index 327fa36..674da89 100644
--- a/src/map/magic.c
+++ b/src/map/magic.c
@@ -93,6 +93,12 @@ magic_message(character_t *caster,
fprintf(stderr, "Found spell `%s', triggered = %d\n", spell_, effects != NULL);
#endif
+ MAP_LOG("PC%d %d:%d,%d CAST %s %s",
+ caster->status.char_id, caster->bl.m, caster->bl.x, caster->bl.y,
+ spell->name,
+ effects? "SUCCESS" : "FAILURE");
+
+
if (effects) {
invocation_t *invocation = spell_instantiate(effects, env);
diff --git a/src/map/map.c b/src/map/map.c
index cf50dfc..98be77b 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1656,6 +1656,28 @@ int map_delmap(char *mapname) {
extern char *gm_logfile_name;
+FILE *map_logfile = NULL;
+
+static void
+map_pclose_map_logfile()
+{
+ pclose(map_logfile);
+}
+
+static void
+map_setlogfile(const char *filename)
+{
+ char *filename_buf = malloc(strlen (filename) + 50);
+ sprintf(filename_buf, "gzip -c > %s", filename);
+ map_logfile = popen(filename_buf, "w");
+ if (!map_logfile)
+ perror(filename);
+ else
+ atexit(map_pclose_map_logfile);
+ free(filename_buf);
+ MAP_LOG("log-start");
+}
+
/*==========================================
* 設定ファイルを読み込む
*------------------------------------------
@@ -1725,6 +1747,8 @@ int map_config_read(char *cfgName) {
strcpy(mapreg_txt, w2);
} else if (strcmpi(w1, "gm_log") == 0) {
gm_logfile_name = strdup(w2);
+ } else if (strcmpi(w1, "log_file") == 0) {
+ map_setlogfile(w2);
} else if (strcmpi(w1, "import") == 0) {
map_config_read(w2);
}
diff --git a/src/map/map.h b/src/map/map.h
index c4e914f..71b091a 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -2,8 +2,10 @@
#ifndef _MAP_H_
#define _MAP_H_
+#include <stdio.h>
#include <stdarg.h>
#include <time.h>
+#include <sys/time.h>
#include "mmo.h"
#ifndef MAX
@@ -684,6 +686,16 @@ int map_quit(struct map_session_data *);
// npc
int map_addnpc(int,struct npc_data *);
+extern FILE *map_logfile;
+#define MAP_LOG(format, args...) \
+ if (map_logfile) { \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ fprintf(map_logfile, "%ld.%06ld ", (long)tv.tv_sec, (long) tv.tv_usec); \
+ fprintf(map_logfile, format, ##args); \
+ fputc('\n', map_logfile); \
+ }
+
// 床アイテム関連
int map_clearflooritem_timer(int,unsigned int,int,int);
#define map_clearflooritem(id) map_clearflooritem_timer(0,0,id,1)
diff --git a/src/map/mob.c b/src/map/mob.c
index 09395f6..f04ff28 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2425,6 +2425,8 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
return 0;
}
+ MAP_LOG("MOB%d DEAD", md->bl.id);
+
// ----- ここから死亡処理 -----
map_freeblock_lock();
diff --git a/src/map/pc.c b/src/map/pc.c
index 34cb59a..82c3584 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -38,6 +38,27 @@
#define STATE_BLIND 0x10
+#define MAP_LOG_PC(sd, fmt, args...) MAP_LOG("PC%d %d:%d,%d " fmt, sd->status.char_id, sd->bl.m, sd->bl.x, sd->bl.y, ## args)
+
+#define MAP_LOG_STATS(sd, suffix) \
+ MAP_LOG_PC(sd, "STAT %d %d %d %d %d %d " suffix, \
+ sd->status.str, sd->status.agi, sd->status.vit, sd->status.int_, sd->status.dex, sd->status.luk)
+
+#define MAP_LOG_XP(sd, suffix) \
+ MAP_LOG_PC(sd, "XP %d %d ZENY %d + %d " suffix, \
+ sd->status.base_level, sd->status.base_exp, sd->status.zeny, pc_readaccountreg(sd, "BankAccount"))
+
+#define MAP_LOG_MAGIC(sd, suffix) \
+ MAP_LOG_PC(sd, "MAGIC %d %d %d %d %d %d EXP %d %d " suffix, \
+ sd->status.skill[TMW_MAGIC].lv, \
+ sd->status.skill[TMW_MAGIC_LIFE].lv, \
+ sd->status.skill[TMW_MAGIC_WAR].lv, \
+ sd->status.skill[TMW_MAGIC_TRANSMUTE].lv, \
+ sd->status.skill[TMW_MAGIC_NATURE].lv, \
+ sd->status.skill[TMW_MAGIC_ETHER].lv, \
+ pc_readglobalreg(sd, "MAGIC_EXPERIENCE") & 0xffff, \
+ (pc_readglobalreg(sd, "MAGIC_EXPERIENCE") >> 24) & 0xff)
+
static int max_weight_base[MAX_PC_CLASS];
static int hp_coefficient[MAX_PC_CLASS];
static int hp_coefficient2[MAX_PC_CLASS];
@@ -660,6 +681,10 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio
return 1;
}
+ MAP_LOG_STATS(sd, "LOGIN");
+ MAP_LOG_XP(sd, "LOGIN");
+ MAP_LOG_MAGIC(sd, "LOGIN");
+
memset(&sd->state, 0, sizeof(sd->state));
// ソスソスソス{ソスIソスネ擾ソスソスソスソスソス
sd->state.connect_new = 1;
@@ -2878,6 +2903,8 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount)
struct item_data *data;
int i,w;
+ MAP_LOG_PC(sd, "PICKUP %d %d", item_data->nameid , amount);
+
nullpo_retr(1, sd);
nullpo_retr(1, item_data);
@@ -4372,6 +4399,8 @@ int pc_gainexp_reason(struct map_session_data *sd,int base_exp,int job_exp, int
if((battle_config.pvp_exp == 0) && map[sd->bl.m].flag.pvp) // [MouseJstr]
return 0; // no exp on pvp maps
+ MAP_LOG_PC(sd, "GAINXP %d %s", base_exp, ((reason == 2)? "SCRIPTXP" : ((reason == 1) ? "HEALXP" : "KILLXP")));
+
if(sd->sc_data[SC_RICHMANKIM].timer != -1) { // added bounds checking [Vaalris]
base_exp += base_exp*(25 + sd->sc_data[SC_RICHMANKIM].val1*25)/100;
job_exp += job_exp*(25 + sd->sc_data[SC_RICHMANKIM].val1*25)/100;
@@ -4629,6 +4658,8 @@ int pc_statusup(struct map_session_data *sd,int type)
pc_calcstatus(sd,0);
clif_statusupack(sd,type,1,val);
+ MAP_LOG_STATS(sd, "STATUP");
+
return 0;
}
@@ -4704,6 +4735,7 @@ int pc_statusup2(struct map_session_data *sd,int type,int val)
clif_updatestatus(sd,type);
pc_calcstatus(sd,0);
clif_statusupack(sd,type,1,val);
+ MAP_LOG_STATS(sd, "STATUP2");
return 0;
}
@@ -4863,6 +4895,8 @@ int pc_resetlvl(struct map_session_data* sd,int type)
clif_skillinfoblock(sd);
pc_calcstatus(sd,0);
+ MAP_LOG_STATS(sd, "STATRESET");
+
return 0;
}
/*==========================================
@@ -4973,6 +5007,12 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
skill_gangsterparadise(sd,0);
}
+ if (src->type == BL_PC) {
+ MAP_LOG_PC(sd, "INJURED-BY PC%d FOR %d", ((struct map_session_data *)src)->status.char_id, damage);
+ } else {
+ MAP_LOG_PC(sd, "INJURED-BY MOB%d FOR %d", src->id, damage);
+ }
+
// ソスソス ソスソスソストゑソスソスソスソス迹ォソスソスソス~ソス゚ゑソス
if(sd->sc_data[SC_ENDURE].timer == -1 && !sd->special_state.infinite_endure)
pc_stop_walking(sd,3);
@@ -5010,6 +5050,8 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
return 0;
}
+ MAP_LOG_PC(sd, "DEAD%s", "");
+
// Character is dead!
sd->status.hp = 0;
@@ -7740,5 +7782,7 @@ int pc_logout(struct map_session_data *sd) // [fate] Player logs out
if (sd->sc_data[SC_POISON].timer != -1)
sd->status.hp = 1; // Logging out while poisoned -> bad
+ MAP_LOG_STATS(sd, "LOGOUT")
+
return 0;
}