summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/emap/homunculus.c24
-rw-r--r--src/emap/homunculus.h10
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/send.c36
-rw-r--r--src/emap/send.h34
6 files changed, 91 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 05ebf01..ad8da26 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,6 +45,8 @@ MAP_SRC = emap/atcommand.c \
emap/effects.h \
emap/hashtable.c \
emap/hashtable.h \
+ emap/homunculus.c \
+ emap/homunculus.h \
emap/horse.c \
emap/horse.h \
emap/init.c \
diff --git a/src/emap/homunculus.c b/src/emap/homunculus.c
new file mode 100644
index 0000000..df9bafb
--- /dev/null
+++ b/src/emap/homunculus.c
@@ -0,0 +1,24 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#include "common/hercules.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "common/HPMi.h"
+#include "common/nullpo.h"
+
+#include "emap/send.h"
+
+int ehomunculus_gainexp_pre(struct homun_data **hdPtr,
+ unsigned int *expPtr)
+{
+ struct homun_data *hd = *hdPtr;
+ nullpo_ret(hd);
+ const int exp = *expPtr;
+
+ send_homun_exp(hd, exp);
+ return 0;
+}
diff --git a/src/emap/homunculus.h b/src/emap/homunculus.h
new file mode 100644
index 0000000..591e612
--- /dev/null
+++ b/src/emap/homunculus.h
@@ -0,0 +1,10 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#ifndef EVOL_MAP_HOMUNCULUS
+#define EVOL_MAP_HOMUNCULUS
+
+int ehomunculus_gainexp_pre(struct homun_data **hdPtr,
+ unsigned int *expPtr);
+
+#endif // EVOL_MAP_HOMUNCULUS
diff --git a/src/emap/init.c b/src/emap/init.c
index 4ac951d..df62add 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -50,6 +50,7 @@
#include "emap/craft.h"
#include "emap/craftconf.h"
#include "emap/hashtable.h"
+#include "emap/homunculus.h"
#include "emap/itemdb.h"
#include "emap/lang.h"
#include "emap/mail.h"
@@ -259,6 +260,7 @@ HPExport void plugin_init (void)
addHookPre(script, hardcoded_constants, escript_hardcoded_constants_pre);
addHookPre(status, calc_pc_additional, estatus_calc_pc_additional_pre);
addHookPre(status, set_viewdata, estatus_set_viewdata_pre);
+ addHookPre(homun, gainexp, ehomunculus_gainexp_pre);
addHookPost(clif, addcards, eclif_addcards_post);
addHookPost(clif, addcards2, eclif_addcards2_post);
diff --git a/src/emap/send.c b/src/emap/send.c
index ee1385a..a570ec0 100644
--- a/src/emap/send.c
+++ b/src/emap/send.c
@@ -10,10 +10,12 @@
#include "common/HPMi.h"
#include "common/memmgr.h"
#include "common/mmo.h"
+#include "common/nullpo.h"
#include "common/socket.h"
#include "common/strlib.h"
#include "common/timer.h"
#include "map/clif.h"
+#include "map/homunculus.h"
#include "map/mob.h"
#include "map/npc.h"
#include "map/pc.h"
@@ -25,7 +27,7 @@
#include "emap/data/session.h"
#include "emap/struct/sessionext.h"
-void send_npccommand (TBL_PC *sd, int npcId, int cmd)
+void send_npccommand (struct map_session_data *sd, int npcId, int cmd)
{
if (!sd)
return;
@@ -42,7 +44,7 @@ void send_npccommand (TBL_PC *sd, int npcId, int cmd)
}
// 0 - get client lang
-void send_npccommand2 (TBL_PC *sd, int npcId, int cmd, int id, int x, int y)
+void send_npccommand2 (struct map_session_data *sd, int npcId, int cmd, int id, int x, int y)
{
if (!sd)
return;
@@ -184,12 +186,12 @@ void send_pc_info(struct block_list* bl1,
return;
char buf[14];
- TBL_PC *sd = (TBL_PC *)bl1;
+ struct map_session_data *sd = (struct map_session_data *)bl1;
struct SessionExt *data = session_get_bysd(sd);
if (!data)
return;
- TBL_PC *tsd = (TBL_PC *)bl2;
+ struct map_session_data *tsd = (struct map_session_data *)bl2;
if (tsd)
{
struct SessionExt *tdata = session_get_bysd(tsd);
@@ -215,7 +217,7 @@ void send_npc_info(struct block_list* bl1,
if (!bl1 || bl1->type != BL_NPC)
return;
- TBL_PC *tsd = (TBL_PC *)bl2;
+ struct map_session_data *tsd = (struct map_session_data *)bl2;
if (tsd)
{
struct SessionExt *tdata = session_get_bysd(tsd);
@@ -290,7 +292,7 @@ void send_changemusic_brodcast(const int map, const char *music)
aFree(buf);
}
-void send_changenpc_title (TBL_PC *sd, const int npcId, const char *name)
+void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name)
{
if (!sd || !name)
return;
@@ -319,7 +321,7 @@ void send_join_ack(int fd, const char *const name, int flag)
WFIFOSET (fd, 27);
}
-void send_slave_say(TBL_PC *sd,
+void send_slave_say(struct map_session_data *sd,
struct block_list *bl,
const char *const name,
const char *const message)
@@ -349,7 +351,7 @@ void send_online_list(int fd, const char *buf, unsigned size)
WFIFOSET (fd, len);
}
-void send_client_command(TBL_PC *sd, const char *const command)
+void send_client_command(struct map_session_data *sd, const char *const command)
{
if (!command)
return;
@@ -491,3 +493,21 @@ void send_walk_fail(int fd, int x, int y)
WFIFOW(fd, 8) = y;
WFIFOSET(fd, 10);
}
+
+void send_homun_exp(struct homun_data *hd,
+ const int exp)
+{
+ nullpo_retv(hd);
+ nullpo_retv(hd->master);
+
+ const int fd = hd->master->fd;
+ struct SessionExt *data = session_get(fd);
+ if (!data || data->clientVersion < 18)
+ return;
+
+ WFIFOHEAD(fd, 10);
+ WFIFOW(fd, 0) = 0xb22;
+ WFIFOL(fd, 2) = exp;
+ WFIFOL(fd, 6) = 0;
+ WFIFOSET(fd, 10);
+}
diff --git a/src/emap/send.h b/src/emap/send.h
index d2d6397..583f12b 100644
--- a/src/emap/send.h
+++ b/src/emap/send.h
@@ -4,8 +4,16 @@
#ifndef EVOL_MAP_SEND
#define EVOL_MAP_SEND
-void send_npccommand (TBL_PC *sd, int npcId, int cmd);
-void send_npccommand2 (TBL_PC *sd, int npcId, int cmd, int id, int x, int y);
+enum send_target;
+
+struct block_list;
+struct homun_data;
+struct item_data;
+struct map_session_data;
+struct unit_data;
+
+void send_npccommand (struct map_session_data *sd, int npcId, int cmd);
+void send_npccommand2 (struct map_session_data *sd, int npcId, int cmd, int id, int x, int y);
void send_local_message(int fd, struct block_list* bl, const char* msg);
void send_changelook(struct map_session_data* sd, struct map_session_data* sd2, int fd,
int id, int type, int val, int val2,
@@ -15,7 +23,7 @@ void send_mapmask_brodcast(const int map, const int mask);
void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_target target);
void send_advmoving(struct unit_data* ud, bool moving, struct block_list *tbl, enum send_target target);
void send_changemusic_brodcast(const int map, const char *music);
-void send_changenpc_title (TBL_PC *sd, const int npcId, const char *name);
+void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name);
void send_join_ack(int fd, const char *const name, int flag);
void send_pc_info(struct block_list* bl1,
struct block_list* bl2,
@@ -23,16 +31,22 @@ void send_pc_info(struct block_list* bl1,
void send_npc_info(struct block_list* bl1,
struct block_list* bl2,
enum send_target target);
-void send_slave_say(TBL_PC *sd,
+void send_slave_say(struct map_session_data *sd,
struct block_list *bl,
const char *const name,
const char *const message);
void send_online_list(int fd, const char *buf, unsigned size);
-void send_client_command(TBL_PC *sd, const char *const command);
-void send_changelook2(struct map_session_data* sd, struct block_list *bl,
- int id, int type,
- int val, int val2, struct item_data *data, int n,
- enum send_target target);
+void send_client_command(struct map_session_data *sd,
+ const char *const command);
+void send_changelook2(struct map_session_data* sd,
+ struct block_list *bl,
+ int id,
+ int type,
+ int val,
+ int val2,
+ struct item_data *data,
+ int n,
+ enum send_target target);
void send_setwall(int m,
int layer,
int x1, int y1,
@@ -53,5 +67,7 @@ void send_pc_killed(int fd,
void send_walk_fail(int fd,
int x,
int y);
+void send_homun_exp(struct homun_data *hd,
+ const int exp);
#endif // EVOL_MAP_SEND